You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an enum variant is referenced within a next block or procedure within a module, a "Type error ... Unknown identifier [variant name]" error is reported erroneously if the enum type is not imported in main.
Minimal example
module m1 {
type op_t = enum { ADD, SUB };
type non_enum_t = integer;
// var g_inst : op_t; // Uncommenting this line fixes the issue
init { }
next {
var inst : op_t;
var n : non_enum_t;
inst = ADD;
n = 100;
}
}
module main {
// type op_t = m1.op_t; // Uncommenting this line ALSO fixes the issue
instance i : m1 ();
next {
next (i);
}
control { }
}
Running this file causes the error on latest master (e244310). The workaround, as suggested by the comments in the above example, is to import the enum type in the main module being run.
More details
The type error is still reported if the enum type is defined in another external module (for example, if type op_t were defined in some other module m0, and imported in m1).
Declaring a global variable in m1 with the type of the enum in question also fixes the error somehow (see code example above).
The text was updated successfully, but these errors were encountered:
Ok, this is definitely a bug, caused by having local variables in next that have types that are only in the submodule. I'll fix this.
btw there's not often much benefit to having local variables in uclid (as in, there's not usually much/any additional cost to having them be module level variables instead of local to the next block)
If an enum variant is referenced within a next block or procedure within a module, a "Type error ... Unknown identifier [variant name]" error is reported erroneously if the enum type is not imported in main.
Minimal example
Running this file causes the error on latest master (
e244310
). The workaround, as suggested by the comments in the above example, is to import the enum type in the main module being run.More details
type op_t
were defined in some othermodule m0
, and imported inm1
).m1
with the type of the enum in question also fixes the error somehow (see code example above).The text was updated successfully, but these errors were encountered: