"I think a good error message would be “Cannot modify an immutable Int (42)”, or whatever else which includes the value itself."
Agree. Wherever possible, error messages should show exactly what upset them. The authors of the message generator know what they're complaining about, but that doesn't help the owner of the offending code (or data) find it.