Skip to content

Conversation

@kerams
Copy link
Contributor

@kerams kerams commented Jun 13, 2023

Fixes #15361, fixes #7670.

Before and after

devenv_rh3jLBLjPb devenv_U7W79EhJHt

@kerams kerams requested a review from a team as a code owner June 13, 2023 19:52
@baronfel
Copy link
Member

baronfel commented Jun 13, 2023

Why does f2 error on the string, but f3 errors on the int list? Naively I expect the first element to 'fix' the element type of the seq CE. EDIT: I cannot read, let this sit here as monument to my lack of literacy.

@kerams
Copy link
Contributor Author

kerams commented Jun 13, 2023

f2 has a type annotation. The type hints make it harder to spot.

@kerams
Copy link
Contributor Author

kerams commented Jun 14, 2023

On an unrelated note, not sure if this is an inherent limitation of implicit yields or just an oversight:

> let y = [ yield 1L; if true then yield 2 ];;
val y: int64 list = [1L; 2L]

> let y = [ 1L; if true then 2 ];;

  let y = [ 1L; if true then 2 ];;
  --------^^^^^^^^^^^^^^^^^^^^^^

stdin(6,9): error FS0193: Type constraint mismatch. The type
    'int'
is not compatible with type
    'int64'

@vzarytovskii vzarytovskii enabled auto-merge (squash) June 14, 2023 08:12
@vzarytovskii vzarytovskii merged commit 8a0d4d0 into dotnet:main Jun 14, 2023
@kerams kerams deleted the m branch June 14, 2023 10:12
@psfinaki
Copy link
Contributor

Thanks @kerams, with PRs like this it really feels like we are cutting off all the rough edges in the language and it's nearing perfection :)

@vzarytovskii
Copy link
Member

On an unrelated note, not sure if this is an inherent limitation of implicit yields or just an oversight:

> let y = [ yield 1L; if true then yield 2 ];;
val y: int64 list = [1L; 2L]

> let y = [ 1L; if true then 2 ];;

  let y = [ 1L; if true then 2 ];;
  --------^^^^^^^^^^^^^^^^^^^^^^

stdin(6,9): error FS0193: Type constraint mismatch. The type
    'int'
is not compatible with type
    'int64'

I think it's an oversight when we were doing implicit conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Incorrect error range in mixed lists with yield! Adding a let binding in list gives the wrong error and increases the error range to the whole list

7 participants