Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop variable, type inference #4583

Open
michaellilltokiwa opened this issue Jan 10, 2025 · 0 comments
Open

loop variable, type inference #4583

michaellilltokiwa opened this issue Jan 10, 2025 · 0 comments
Labels
enhancement New feature or request front end related to the front end until .fum file is created: call and type resolution, type checking, etc.

Comments

@michaellilltokiwa
Copy link
Member

michaellilltokiwa commented Jan 10, 2025

In this example Sequence i32 could be automatically chosen to be the type of x.

ex =>

  for
    x := [2], x.map id
  do
    say x
/home/sam/playground/test.fz:4:5: error 1: Incompatible types when passing argument in a call
    x := [2], x.map id

Actual type for argument #1 'x' does not match expected type.
In call to          : 'ex.loop'
expected formal type: 'array i32'
actual type found   : 'Sequence i32'
assignable to       : 'Sequence i32'
for value assigned  : 'x'
To solve this, you could change the type of the target 'x' to 'Sequence i32' or convert the type of the assigned value to 'array i32'.

one error.

We only should choose one of the types. Not some common super type:

In this case (array i32 and list i32) we do not want to automatically choose Sequence i32.

ex =>

  for
    x := [2], x.as_list
  do
    say x
@michaellilltokiwa michaellilltokiwa added enhancement New feature or request front end related to the front end until .fum file is created: call and type resolution, type checking, etc. labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request front end related to the front end until .fum file is created: call and type resolution, type checking, etc.
Projects
None yet
Development

No branches or pull requests

1 participant