Difficulty Implementing New Attribute

Hi all,

I'm trying to implement a new attribute @_synthesized in the compiler. Looking at other PRs, I added its definition to Attr.def:

SIMPLE_DECL_ATTR(_synthesized, Synthesized,
  OnFunc | OnVar | OnSubscript | OnConstructor |
  UserInaccessible | 
  ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIStableToRemove, 
  130)

I also added some diagnostics in DiagnosticsSema.def and added it as an ignored attribute in TypeCheckAttr.cpp:

// In class AttributeChecker:
IGNORED_ATTR(Synthesized)

Lastly, I made it an uninteresting attribute in TypeCheckDeclOverride.cpp:

// In class AttributeOverrideChecker
UNINTERESTING_ATTR(Synthesized)

After these changes I get the error:

swift-project/swift/lib/Serialization/DeclTypeRecordNodes.def:149:1: error: duplicate case value: 'Synthesized_DECL_ATTR' and 'TUPLE_PATTERN' both equal '201'
PATTERN(TUPLE)
^

I've reviewed some PRs that implement new attributes again and again but couldn't find what I am doing wrong, so what am I missing?

Thanks in advance!

Did you bump the SWIFTMODULE_VERSION_MINOR?

We did recently run out of serialization codes for attributes, so yeah, we really need to move codes around and bump the format.

Yes, I forgot to mention that.

Is there something I can do in the meantime or should I just wait until these changes land on main?

I've made room; please pull and try now.

3 Likes