You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The exception type is normally a type like any other except we require it to be a variant so that throwing functions will compose.
But we can't use the normal type syntax with brackets for variants as that makes it impossible to distinguish exception type from return type when we specify only one of them:
fn f1(): [] # is `[]` the exception type or return type?
We currently only accept a special kind of variant syntax where delimiters are braces instead of brackets.
Ideally there should be one variant syntax, so we should use [].
Another issue is requiring only variants in the exception type position also makes it impossible to have a function like:
fn f2(): r ()
Instead we have to do:
fn f3(): {..r} ()
Which is the same thing if we only allow throwing variants (which we do currently), but more verbose.
I spent way too much time trying to come up with a syntax that lalrpop will accept. For now I'll merge this syntax as-is but we should fix this soon.
One of the other syntax that I've tried is with ~ prefix for the exception type, e.g.
Mark the exception types in signatures to distinguish exception type from return type when there's only one type after :. I'm thinking ! may be an option for this: !errs.
Or: require two or zero types, i.e. if you specify one of the return type of exception type you specify the other as well.
I don't like this too much as I'd like to infer exception types in the future.
The text was updated successfully, but these errors were encountered:
This syntax is not in
main
yet, but it will be soon.In the
exceptions
branch (#51) we use braces for exceptions of a function:The exception type is normally a type like any other except we require it to be a variant so that throwing functions will compose.
But we can't use the normal type syntax with brackets for variants as that makes it impossible to distinguish exception type from return type when we specify only one of them:
We currently only accept a special kind of variant syntax where delimiters are braces instead of brackets.
Ideally there should be one variant syntax, so we should use
[]
.Another issue is requiring only variants in the exception type position also makes it impossible to have a function like:
Instead we have to do:
Which is the same thing if we only allow throwing variants (which we do currently), but more verbose.
I spent way too much time trying to come up with a syntax that lalrpop will accept. For now I'll merge this syntax as-is but we should fix this soon.
One of the other syntax that I've tried is with
~
prefix for the exception type, e.g.However that causes LR(1) issues, if the exception type is
A
and a[
follows:The parser can reduce
A
as a type, or shift[
and try to parse a type argument like inA[U32]
.So we need two things:
:
. I'm thinking!
may be an option for this:!errs
.I don't like this too much as I'd like to infer exception types in the future.
The text was updated successfully, but these errors were encountered: