Skip to content

Conversation

@kazcw
Copy link
Contributor

@kazcw kazcw commented Oct 7, 2025

Remove operator section boundary AST nodes; enable warning for unused operator sections, which was implemented in #13920 (fixes #11203).

OprSectionBoundary nodes, 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:

  • 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.

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

… 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.
@kazcw kazcw self-assigned this Oct 7, 2025
@kazcw kazcw added the CI: No changelog needed Do not require a changelog entry for this PR. label Oct 7, 2025
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Contributor

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).
Copy link
Contributor

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?

Copy link
Contributor

@GregoryTravis GregoryTravis left a comment

Choose a reason for hiding this comment

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

Libs approval

Copy link
Member

@JaroslavTulach JaroslavTulach left a 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]
```
Copy link
Member

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();
Copy link
Member

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" <|
Copy link
Member

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!

@kazcw kazcw merged commit 48fa8f8 into develop Oct 13, 2025
143 of 155 checks passed
@kazcw kazcw deleted the wip/kw/consistent-opr-sections branch October 13, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: No changelog needed Do not require a changelog entry for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Yield error when operator section is used in statement context

6 participants