Skip to content

Generated class names can clash #79

@shilangyu

Description

@shilangyu

Currently, to pick a class name for a contract statement the following is done:

  1. Take the statement name
  2. If it collides with any other statement name (regardless of their namespace), then go one namespace up and prefix your current name with the namespace name
  3. Repeat step 2 until there are no more conflicts

For instance consider two statements One.Two.Three and Four.Two.Three where . denotes a namespace accessor.

Then to find the class name for One.Two.Three:

  1. Start with Three
  2. It collides with Four.Two.Three, go one namespace up: set current name to TwoThree
  3. Still collides with Four.Two.Three, go one namespace up: set current name to OneTwoThree
  4. No collisions. Final class name is OneTwoThree

This algorithm was chosen because Dart does not have namespaces and this algorithm produces possibly shortest names without collisions... Or so I thought.

Now consider the following statements: One.One, OneOne, Two.One. If you follow the algorithm, the resulting class names will be respectively OneOne, OneOne, and TwoOne. That's a name clash.

This brings us to the question: how do we want to generate names for such cases? Or, what would be a different (better) way of picking class names?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions