core: support raise exception short form #455

Merged
sb10q merged 1 commits from issue-194 into master 2024-07-12 18:58:35 +08:00
Collaborator

Adds support for "raise Exception" short form #194

Exceptions can now be raised using either of these syntaxes:

@kernel
    def run(self):
        raise ZeroDivisionError
@kernel
    def run(self):
        raise ZeroDivisionError()
Adds support for "raise Exception" short form #194 Exceptions can now be raised using either of these syntaxes: ``` @kernel def run(self): raise ZeroDivisionError ``` ``` @kernel def run(self): raise ZeroDivisionError() ```
sb10q reviewed 2024-07-10 16:09:56 +08:00
@ -2461,0 +2460,4 @@
if let Some(res) = resolver.get_symbol_value(*id, ctx) {
res
} else {
// Allow "raise Exception" short form (Issue #194)
Owner

No need to quote issue number.

Why is the code so complicated?

No need to quote issue number. Why is the code so complicated?
Author
Collaborator

No need to quote issue number.

Ok.

Why is the code so complicated?

The shorthand exception notation is treated as a variable in the AST. Here I am performing a lookup using the variable definition to get the signature of the exception. Most of the code is to ensure the exception is matched to correct type.

> No need to quote issue number. Ok. > Why is the code so complicated? The shorthand exception notation is treated as a variable in the AST. Here I am performing a lookup using the variable definition to get the signature of the exception. Most of the code is to ensure the exception is matched to correct type.
Owner

Sounds fishy to me. The other one would be a variable inside a call, so there shouldn't be that much difference.

Sounds fishy to me. The other one would be a variable inside a call, so there shouldn't be that much difference.
Author
Collaborator

Sounds fishy to me. The other one would be a variable inside a call, so there shouldn't be that much difference.

The other already has the function signature (the constructor of the exception) linked to it, so there is no need for lookup.

> Sounds fishy to me. The other one would be a variable inside a call, so there shouldn't be that much difference. The other already has the function signature (the constructor of the exception) linked to it, so there is no need for lookup.
abdul124 force-pushed issue-194 from 16dac8b2c4 to 52e5d417ea 2024-07-10 17:35:32 +08:00 Compare
sb10q merged commit 513d30152b into master 2024-07-12 18:58:35 +08:00
sb10q deleted branch issue-194 2024-07-12 18:58:35 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#455
No description provided.