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

Macro in global is not working #72655

Open
mtfum opened this issue Mar 28, 2024 · 0 comments
Open

Macro in global is not working #72655

mtfum opened this issue Mar 28, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@mtfum
Copy link

mtfum commented Mar 28, 2024

Description

I've been trying experiments with macro then found interesting behavior.

import Foundation

print(try [0, 1, 2].filter(#Predicate { $0 == 0 }))
print(try [0, 1, 2].filter(#Predicate { $0 == 1 }))

do {
  print(try [0, 1, 2].filter(#Predicate { $0 == 0 }))
  print(try [0, 1, 2].filter(#Predicate { $0 == 1 }))
}
[0]
[0]
[0]
[1]

The second one should be [1] as same as the last elements.
In my opinion, there is a problem with global definition of macro.

Reproduction

import Foundation

print(try [0, 1, 2].filter(#Predicate { $0 == 0 }))
print(try [0, 1, 2].filter(#Predicate { $0 == 1 }))

do {
  print(try [0, 1, 2].filter(#Predicate { $0 == 0 }))
  print(try [0, 1, 2].filter(#Predicate { $0 == 1 }))
}

Expected behavior

[0]
[1]
[0]
[1]

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

Macro expansion of each #Predicate is correct.

Screenshot 2024-03-28 at 9 15 42 PM
@mtfum mtfum added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant