Skip to content

Fold operators using the standard operator table in MacroSystem #2132

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

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 1, 2023

The compiler folds operators in attributes and freestanding macro nodes but MacroSystem wasn’t doing that. But it should to match the compiler behavior.

rdar://114786803
Fixes #2128

@ahoppen
Copy link
Member Author

ahoppen commented Sep 1, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 1, 2023

@swift-ci Please test Windows

in context: MacroExpansionContext,
foldingWith operatorTable: OperatorTable?
) -> Self {
return (detach(in: context, foldingWith: operatorTable) as Syntax).cast(Self.self)
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
return (detach(in: context, foldingWith: operatorTable) as Syntax).cast(Self.self)
return (detach(in: context, foldingWith: operatorTable) as Syntax).cast(Self.self)

What's the as needed for here? Doesn't this already return a Syntax?

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s to disambiguate the version of detach that is being called. Without as Syntax we would have an infinite recursion here.

@ahoppen ahoppen force-pushed the ahoppen/fold-operators branch from 565b396 to 0af1cb8 Compare September 5, 2023 23:43
@ahoppen
Copy link
Member Author

ahoppen commented Sep 5, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 6, 2023

@swift-ci Please test Windows

The compiler folds operators in attributes and freestanding macro nodes but `MacroSystem` wasn’t doing that. But it should to match the compiler behavior.

rdar://114786803
Fixes swiftlang#2128
@ahoppen ahoppen force-pushed the ahoppen/fold-operators branch from 0af1cb8 to 12c0887 Compare September 6, 2023 01:23
@ahoppen
Copy link
Member Author

ahoppen commented Sep 6, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 6, 2023

@swift-ci Please test Windows

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.

No way to describe operator precedence to assertMacroExpansion
2 participants