P: When do two names conflict?

It is not clear to me why the following program compiles

enum Example { e1, e2, e3 }

machine M {
    start state S {
        entry {
            var Example, e1, e2, e3 : int; // shadowing names is commonly allowed in other languages
            var ex : Example; // why is this ok?
        }
    }
}

What is the type of ex in this program? Is it an enum? When do names conflict with each other? Are there multiple namespaces?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

The real bug here is that the compiler is not checking that the prototype matches the machine. Perhaps, this is one of the checks that is being performed in the linker phase, which is supposed to be unified with the compiler.

@alexreinking : For the new compiler, let us go ahead and enforce this check.

The answer to your first problem is: // Names can hide other names in the following order: local variable hides machine variable hides (event name + enum name).

Example is a name of a typedef I don’t think we allow hiding of type names or namespaces.

For the second part it is a mistake. I am checking-in a fix at the parser level that machines and enums types have disjoint names.

Does that solve the problem ?