-
Notifications
You must be signed in to change notification settings - Fork 169
Description
I had instantiated mkCReg, which returns an array of interfaces, but then I changed my mind and made it an ordinary mkReg, but forgot to remove the brackets in some uses. The error message was not great. For example:
module mkTest();
Reg#(Bool) rg <- mkRegU;
rule rl;
rg[0] <= True;
endrule
endmoduleresults in this error message:
Error: "Test.bsv", line 1, column 8: (T0098)
Run-time writes with [] and <= for a value of type:
Reg#(Bool)
require an argument value of type:
_tctyvar1262
Instead, the following argument type was found:
Bool
Writes were performed on this type in or at the following locations:
"Test.bsv", line 5, column 7
The position at the end of the message is correct, and the message does refer to array writes (with [] and <=), so it was possible to figure out the mistake; but the type variable name didn't need to be exposed to the user.
The array write syntax is implemented using a typeclass (PrimWriteable) and context errors for that class that are detected by BSC and reported specially, which is what we're seeing here. However, if the argument type is an un-bound variable, BSC should probably report the error differently.
I notice, for example, that I can't cause the same issue with array assignment (with [] and =):
module mkTest();
rule rl;
Reg#(Bool) b;
b[0] = True;
endrule
endmoduleThat gives the error message:
Error: "Test2.bsv", line 4, column 6: (T0095)
Compile-time updates with [] and = are not defined for the type:
Reg#(Bool)