Bug introduced in 8.0 or earlier and fixed in 10.1
When assigning message to a symbol localized by Block
, I would expect that this message is not accessible outside of Block
, but I observe different behavior:
ClearAll[x]
Block[{x}, x::test1 = "message1"];
x::test1
(* "message1" *)
Message was assigned to x
globally regardless of x
being localized.
It also happens with direct assignment to Messages
:
ClearAll[x]
Block[{x}, Messages[x] = {HoldPattern[x::test2] :> "message2"}];
x::test2
(* "message2" *)
I get this behavior in all versions I have available: 8.0.0, 9.0.1 and 10.0.0 on Linux.
Is this a bug?
MessageName
has certain auto-stringification step, which allows the second argument of MessageName to be a symbol. When the definition is constructed, it is auto-stringified, but then still attached to the symbol. From the point of view of whatBlock
is supposed to do, this can be probably considered a bug. $\endgroup$Messages
list. IsMessageName
involved also in this kind of assignment? $\endgroup$MessageName
specifically, but I think that the underlying mechanism used to attach message(s) to symbol(s) should be the same in both cases. And it is this mechanism whose interaction withBlock
looks problematic. $\endgroup$bugs
tag to this one? $\endgroup$