Skip to content

->! parsed as operator #5151

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

Open
michaellilltokiwa opened this issue Apr 28, 2025 · 1 comment
Open

->! parsed as operator #5151

michaellilltokiwa opened this issue Apr 28, 2025 · 1 comment
Labels
front end related to the front end until .fum file is created: call and type resolution, type checking, etc. Fuzion language related to the language, syntax, etc

Comments

@michaellilltokiwa
Copy link
Member

Might be a bit surprising that ->! is parsed as an operator.
May be it is more reasonable to always consider ->... as the lambda arrow + start of a new expression.

ex =>

  [true]
    .filter x->!x

/home/sam/playground/test.fz:4:13: error 1: Could not find called feature
    .filter x->!x

Feature not found: 'x' (no arguments)
Target feature: 'ex'
In call: 'x'
Lambda operator is part of infix operator here:
/home/sam/playground/test.fz:4:14:
    .filter x->!x

To solve this, add a space after '->'.

one error.
@michaellilltokiwa michaellilltokiwa added front end related to the front end until .fum file is created: call and type resolution, type checking, etc. Fuzion language related to the language, syntax, etc labels Apr 28, 2025
@fridis
Copy link
Member

fridis commented Apr 28, 2025

Yes, this is surprising, but it is somewhat arbitrary to automatically split off ->, other operators with special handling then might need the same treatment like =>, :=, ., |, .., ..., :, !, maybe some more.

I think the simple rule that a sequence of a letter followed by letter/digit is always an identifier (unless this forms a keyword), while a sequence of operator codepoints is always an operator (unless it is a special operator) is nice to have.

What we can enhance, however, is the error message in this case, it should also suggest using parentheses (/).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front end related to the front end until .fum file is created: call and type resolution, type checking, etc. Fuzion language related to the language, syntax, etc
Projects
None yet
Development

No branches or pull requests

2 participants