-
-
Notifications
You must be signed in to change notification settings - Fork 45
Use K"function" for short form function AST
#466
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K"function" for short form funtion ASTK"function" for short form function AST
|
looks good to me. Does it handle all 4 of these? f(x) = 10
f(x)::R = 10
f(x::T) where T = 10
f(x::T)::R where T = 10 |
Closed
This is semantically incorrect and will be caught by lowering. But technically making it a parser error would be breaking :-(
This is a simple fix for the tests, but a better solution is to make Expr equivalence more permissive to accommodate having better line information in the new parser!
6eab9b6 to
6694b89
Compare
Member
Author
Yes! |
This form isn't a short form function definition, so should be parsed with `=` kind.
c42f
added a commit
to JuliaLang/julia
that referenced
this pull request
Oct 17, 2025
…jl#466) A pain point when writing macros is detecting all the types of things which might be lowered to functions. This is partly due to the existence of short form function definitions which in Julia's classic AST parse with `:(=)` rather than a `:function` head - to detect the meaning of `=`, one needs to traverse recursively into the left hand side of the expression. This change modifies the parsing of short form functions to use the `K"function"` kind. A new syntax flag `SHORT_FORM_FUNCTION_FLAG` is set to enable AST consumers to detect short vs long form functions.
topolarity
pushed a commit
to JuliaLang/julia
that referenced
this pull request
Nov 14, 2025
…jl#466) A pain point when writing macros is detecting all the types of things which might be lowered to functions. This is partly due to the existence of short form function definitions which in Julia's classic AST parse with `:(=)` rather than a `:function` head - to detect the meaning of `=`, one needs to traverse recursively into the left hand side of the expression. This change modifies the parsing of short form functions to use the `K"function"` kind. A new syntax flag `SHORT_FORM_FUNCTION_FLAG` is set to enable AST consumers to detect short vs long form functions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #465 - see rationale there.
Fixing this turned out to be quite easy.
Compat:
Expr