Accessor macro executing wrong code #71070
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
macro expansions
Feature → expressions: Macro expansion expressions
swift macro
Feature → declarations: Swift `macro` declarations
Description
We've implemented a macro similar to
@ObservationTracked
that swaps out a stored property for accessors that call down to some private storage. Much to my surprise, though, that private storage is not being called.See attached for repro: MyMacro.zip
Reproduction
Macro plugin:
Library:
Executable:
What the above should expand to:
Expected behavior
I expect
foo.bar()
to crash in the executable because@MyMacro
has swappedvar bar
for a getter that invokes_bar
, which is a member that defaults to callingfatalError()
.Instead, I get
false
printed to the console, which shows that Swift is somehow invoking the original storage.Environment
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: