Skip to content

Tighten unary op syntax and untupling language#14372

Merged
anatoliykmetyuk merged 2 commits into
scala:mainfrom
som-snytt:issue/9241
Mar 8, 2022
Merged

Tighten unary op syntax and untupling language#14372
anatoliykmetyuk merged 2 commits into
scala:mainfrom
som-snytt:issue/9241

Conversation

@som-snytt

Copy link
Copy Markdown
Contributor

Fixes #9241

Disallow unary ops with parens.

Follow up untupling spec where it is not pattern-matching like .tupled. It simply takes the params it knows to take.

@anatoliykmetyuk anatoliykmetyuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Otherwise LGTM

Comment thread docs/docs/reference/changed-features/operators.md Outdated
Comment thread docs/docs/reference/changed-features/operators.md Outdated
@som-snytt

Copy link
Copy Markdown
Contributor Author

It's not obvious to me that the reason I can't define

def unary_!() = false

is that I wouldn't be able to write prefix op syntax. What if I had no intention of using prefix op syntax? Perhaps my purpose was to sabotage prefix syntax for subclasses.

This is probably the only case where syntax restricts a regular language feature. For example, I can write extensions for StringContext that cannot be used as an interpolator.

@som-snytt

Copy link
Copy Markdown
Contributor Author

I used github's "commit suggestion" feature for the first time, but I see that it triggers tests.

@som-snytt

Copy link
Copy Markdown
Contributor Author

Rebased for conflicts, but accidentally lost review tweaks added via suggested edits.

Re-added tweaks per review.

@anatoliykmetyuk anatoliykmetyuk merged commit 808c669 into scala:main Mar 8, 2022
@som-snytt som-snytt deleted the issue/9241 branch March 8, 2022 14:37
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.

Disallow nilary (empty parenthesis) of prefix unary methods

2 participants