Skip to content

Constants in DSL can be defined multiple times #253

@GuillaumeTaffin

Description

@GuillaumeTaffin

Description

A constant defined with the !constant keyword can be overridden, hence is not constants anymore.
This is quite error prone since it allows to easily redefine a constant value in another file (while using includes).

If it is expected behavior, it would probably be interesting to be able to parametrize it to make it stricter (I did not find a way to do it)

Steps to reproduce

  1. Render the snippet in https://structurizr.com/dsl
workspace {
    !constant MICHEL "michel"
    !constant MICHEL "mimich"


    model {
    
        user = person ${MICHEL}
        softwareSystem = softwareSystem "Software System" {
            webapp = container "Web Application" {
                user -> this "Uses"
            }
            container "Database" {
                webapp -> this "Reads from and writes to"
            }
        }
    }

    views {
        systemContext softwareSystem {
            include *
            autolayout lr
        }
    }
}
  1. The second value of the constant MICHEL overrides the first one without issue.

Screenshot

No response

Code sample

No response

Configuration

No response

Severity

Minor

Priority

I have no budget and there's no rush, please fix this for free

More information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions