Skip to content

[FEATURE] Warn when default is used inside a field #331

Description

@Aaron-Hartwig

Describe the problem/limitation you think should be addressed
Today, if a field contains a default property assignment, that assignment is silently dropped. This is not incorrect behavior since defaults apply to children, and fields are leaf notes which can't have children. I think there is an opportunity for the compiler to help out a programmer who is making a mistake.

Describe the solution you'd like
I would like the ability to tell the compiler to treat the "default in a field" behavior as a warning or error. I think the warning and error flags should be extended to support this if a user desires. A case could be made that this should be a warning by default.

Describe alternatives you've considered
I think the alternatives to my proposal here are if the issue should be treated as a warning by default or not.

Additional context
The context for this ask came from a colleague noticing some code we generated from RDL did not have certain fields' software access defined correctly (oxidecomputer/quartz#507). I eventually figured out that the issue was the errant use of default within a field and fixed it (oxidecomputer/quartz#508). This is a mistake that can easily happen so I'd like to be able to prevent it in the future. I have a stab at a warning/error implementation here: Aaron-Hartwig@c3c5ff3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions