Skip to content

Conversation

@jiribenes
Copy link
Contributor

@jiribenes jiribenes commented Nov 28, 2025

Resolves #707

In this PR, we allow more general with val, specifically with val <PATTERN> (, <PATTERN>)* = <EXPR>; <STMTS>.
This comes at a cost: with val x: Int = foreach([1,2,3]); becomes unsupported as the : Int is no longer possible (since it's a pattern and those cannot have type annotations right now).

Comment on lines -14 to +15
with val x: Int = foreach([1,2,3]);
with val (a, b) = bar;
with val x = foreach([1,2,3]);
with val a, b = bar;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change ^ as type annotations are no longer supported and multiple arguments have to be written without the parenthesis.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to support else clauses for exhaustive pattern matching?

Like:

with val Some(v) = foo() else do raise()
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason why not :)
In an ideal case, I'd like to share as much parser code as possible with destructuring ala val (x, Some(y)) = ... (and with lambda-case)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

with val syntax sugar for more complex types

3 participants