Skip to content
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

Ast types first #7233

Merged
merged 10 commits into from
Jan 9, 2025
Merged

Ast types first #7233

merged 10 commits into from
Jan 9, 2025

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Jan 8, 2025

AST: always put type parameters first in function definitions.

Normalize function definitions to be of the form (type a b c, x, y) => ..., moving all the types first if they are not already.

Normalize function definitions to be of the form `(type a b c, x, y) => ...`, moving all the types first if they are not already.
@@ -17,6 +17,11 @@
- Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231
- Fix leftover assert false in code for `null != undefined`. https://github.com/rescript-lang/rescript/pull/7232

#### :house: Internal

- AST cleanup: Prepare for ast async cleanup: Refactor code for "@res.async" payload handling and clean up handling of type and term parameters, so that now each `=>` in a function definition corresponds to a function. https://github.com/rescript-lang/rescript/pull/7223
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missing from previous PR

@@ -1,14 +1,12 @@
let f = (type t, xs: list<t>) => ()
let f = @attr (type t, xs: list<t>) => ()
let f = (type t, xs: list<t>) => (type s, ys: list<s>) => ()
let f = @attr (type t, xs: list<t>) => @attr2 (type s, ys: list<s>) => ()
let f = (type t s, xs: list<t>, ys: list<s>) => ()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was incorrect before. It's a single function.
But if one toggles between types and terms, there's no way to know if trailing types belong to the current function or the next one. Moving all types first removes this ambiguity.

@cristianoc cristianoc requested review from cknitt and zth January 8, 2025 13:35
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Syntax Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 0745025 Previous: e1b7fb7 Ratio
Parse Napkinscript.res - time/run 41.63185150666666 ms 39.28006235333333 ms 1.06

This comment was automatically generated by workflow using github-action-benchmark.


type fundef_term_param = {
attrs: Parsetree.attributes;
p_label: Asttypes.arg_label;
Copy link
Member

Choose a reason for hiding this comment

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

Why are you now using the p_ prefix for label and pos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are other types with the same labels, and it becomes ambiguous.

@cristianoc cristianoc merged commit feb85f2 into master Jan 9, 2025
21 checks passed
@cristianoc cristianoc deleted the ast_types_first branch January 9, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants