-
Notifications
You must be signed in to change notification settings - Fork 334
Consistent operator section semantics (and enable unused operator section warning) #14117
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
Conversation
… operator sections (which was implemented in #13920). `OprSectionBoundary` nodes implemented a designed behaviour that was never put into practice. The nodes were ignored in the frontend and the backend, where an operator section has always included exactly the operator application. This change brings the parser's AST in line with current semantics. Also: - The operand of `UnaryOprApp` is no longer optional in the AST types. The parser already did not construct any `UnaryOprApp` without an operand present; the types now reflect this.
docs/syntax/functions.md
Outdated
| works as follows: | ||
|
|
||
| - When a binary operator is referred to without providing arguments, its value | ||
| is a method applying the operation two its two arguments (left followed by |
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.
| is a method applying the operation two its two arguments (left followed by | |
| is a method applying the operation to its two arguments (left followed by |
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 feel it can be rewritten as “When a binary operator is referred to without providing arguments, its value is a function of two arguments (left operand followed by the right one)”. It is not clear to me why here we use “method”, and in the next sentence we use “function”.
| case RawAst.Tree.Type.OprSectionBoundary: | ||
| // This expression type is not yet consistent with the backend's semantics. | ||
| // The frontend can ignore it, avoiding some problems with expressions sharing spans | ||
| // (which makes it impossible to give assign unique IDs in the current IdMap format). |
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.
This comment is now about TemplateFunction, right?
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.
Libs approval
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.
Thanks a lot for updating the public documentation of Enso language!
| [1, 2, 3].map function=/1 . should_equal [1.0, 2.0, 3.0] | ||
| [1, 2, 3].map 1/ . should_equal [1.0, 0.5, 0.3333333333333333] | ||
| [1, 2, 3].map /1 . should_equal [1.0, 2.0, 3.0] | ||
| ``` |
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.
Thanks for modifying the documentation!
| yield tree; | ||
| } | ||
| case Tree.UnaryOprApp app -> app.getRhs(); | ||
| case Tree.OprSectionBoundary section -> section.getAst(); |
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.
OK, looks like a simplification.
| r4.pretty . should_equal "Table.new [['foo', [1, 2, 3]], ['bar', [False, True, False]], ['date', [Date.new 2022 8 27, Date.new 1999 1 1, Date.new 2012 1 23]], ['time', [Time_Of_Day.new 18, Time_Of_Day.new 1 2 34, Time_Of_Day.new 12]]]" | ||
| Debug.eval r4.pretty . should_equal r4 | ||
|
|
||
| group_builder.specify "allows setting the column type" <| |
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.
Great if the new syntax can discover errors like this!
…opr-sections # Conflicts: # docs/syntax/functions.md
Remove operator section boundary AST nodes; enable warning for unused operator sections, which was implemented in #13920 (fixes #11203).
OprSectionBoundarynodes, and the logic for placing them, implemented a designed behaviour that was never put into practice. The backend (and frontend) were never updated to make use of the nodes, where an operator section has always included exactly the operator application. Given other changes that have been made to the usage of operator sections, the existing semantics are probably preferable. This change brings the parser's AST in line with current semantics.Also:
UnaryOprAppis no longer optional in the AST types. The parser already did not construct anyUnaryOprAppwithout an operand present; the types now reflect this.Pull Request Description
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.