-
-
Notifications
You must be signed in to change notification settings - Fork 46
Use structs instead of NamedTuple's in parse_brackets()
#615
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
base: backports-julialang-1.12
Are you sure you want to change the base?
Use structs instead of NamedTuple's in parse_brackets()
#615
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## backports-julialang-1.12 #615 +/- ##
===========================================================
Coverage ? 96.91%
===========================================================
Files ? 14
Lines ? 4380
Branches ? 0
===========================================================
Hits ? 4245
Misses ? 135
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine if we need it. Though I'd prefer a less invasive alternative if we want to keep the code idiomatic for future Julia versions (assuming 1.13 doesn't suffer from this?)
The simplest least invasive way could be to type assert the type of opts as soon as it's returned? Then the performance hacking is localized in one place?
| end | ||
| end | ||
|
|
||
| @kwdef mutable struct ParseUnaryBracketOpts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of notes:
- Why are these options structs mutable?
- Unfortunately
@kwdefdoesn't exist on older julia versions
| return ParseUnaryBracketOpts(; needs_parameters=is_paren_call, | ||
| is_paren_call=is_paren_call, | ||
| is_block=!is_paren_call && num_semis > 0) | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this do the trick?
| return ParseUnaryBracketOpts(; needs_parameters=is_paren_call, | |
| is_paren_call=is_paren_call, | |
| is_block=!is_paren_call && num_semis > 0) | |
| end | |
| return (needs_parameters=is_paren_call, | |
| is_paren_call=is_paren_call, | |
| is_block=!is_paren_call && num_semis > 0) | |
| end | |
| opts::NamedTuple{(:needs_parameters, :is_paren_call, :is_block), Tuple{Bool, Bool, Bool}} |
@KristofferC, @mlechu, this is a more invasive but reliable (I think) solution to #600. Can confirm that it fixes the invalidations from
parse_brackets()on 1.12 for InitialValues.jl (though there's a plethora of others). If y'all think it's a good idea I can make a PR to the main repo.