Leopold Toetsch via RT wrote:
Let me redo that... I've just sent the wrong attachment which had a typo in it ...
I think, we could be a bit more graceful here for I/N mismatch and set
for the above case the constant val->set to 'N'.
[This should really address rare but possible Unicode strings, shouldn't it?]
Nick
Index: imcc/symreg.c =================================================================== --- imcc/symreg.c (revision 7843) +++ imcc/symreg.c (working copy) @@ -307,6 +307,7 @@ INS(interp, unit, "set_p_pc", "", r, 2, 0, 1); return NULL; } + /* Makes a new identifier constant with value val */ SymReg * mk_const_ident(Interp *interp, @@ -314,6 +315,16 @@ { SymReg *r; + // Forbid assigning a string to anything other than a string const + // for now + if (t != 'S' && val->set == 'S') + IMCC_fataly(interp, E_TypeError, + "bad const initialisation"); + + // Cast value to const type + if (t == 'N' || t == 'I') + val->set = t; + if (global) { if (t == 'P') { IMCC_fataly(interp, E_SyntaxError,