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

if expression: supress incompatible types error after indentation error #3931

Open
simonvonhackewitz opened this issue Oct 14, 2024 · 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

@simonvonhackewitz
Copy link
Contributor

Maybe it would make sense to suppress the second error in the following example.

ex is
  arg => 42
  callWith2Args(a, b i32) => {say "$a $b"; true}
  callWith2Args(a i32)    => {panic "expected two args!"; false}
  callWith2Arg            => {panic "expected two args!"; false}

  if_with_call1 is

    # 'if' requires the condition to be in a single line, doest not allow vertically aligned arguments
    if callWith2Args arg
                     arg  // this arg is parsed as first expr in the then-block
      say "ok"            // 11. should flag an error: wrong indentation
    else
      panic "expected true"

  _ := if_with_call1

> FUZION_DISABLE_ANSI_ESCAPES=true fz /tmp/issue.fz

/tmp/issue.fz:12:7: error 1: Inconsistent indentation
      say "ok"            // 11. should flag an error: wrong indentation
------^
Indentation reference point is /tmp/issue.fz:10:5:
    if callWith2Args arg
----^
While parsing: exprs, parse stack: exprs, block, implRout, implFldOrRout, routOrField, feature, expr, exprs, block, implRout, implFldOrRout, routOrField, feature, expr, exprs, block, unit


/tmp/issue.fz:10:5: error 2: Incompatible types in branches of if expression
    if callWith2Args arg
----^^^^^^^^^^^^^^^^^^^^
                     arg  // this arg is parsed as first expr in the then-block
---------------------^^^
Incompatible result types in different branches:
block returns value of type 'i32' at /tmp/issue.fz:11:22:
                     arg  // this arg is parsed as first expr in the then-block
---------------------^^^
block returns value of type 'unit' at /tmp/issue.fz:10:5:
    if callWith2Args arg
----^

2 errors.
@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 Oct 14, 2024
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

2 participants