Issue 4923 - immutable module variables are modifiable in non-shared module constructors

Check that the right kind of module constructor is used to initialize globals.  Improve error message.

Fixes Issue 4923