@tig said:
I'm not sure if the author Ash is still about... However, it's easy to fix the error - ...
Note the two additions of .dup
code, which copy the 'frozen-string' in the module's name and use that instead, as a frozen-string cannot now be directly changed in code, without this sidestepping...
I just noticed this as I'm not over here at SCF much these days.
It was I who wrote this extension for Ash, long before the frozen string madness.
I did not realize that Module::nesting[i].name
, ... actually Moudle#name
returned a frozen string. Even the Ruby v2.7.2 documentation does not indicate this. (Doesn't indicate much of anything really.)
But it does make sense that all the class and module identifier strings would be frozen (likely linked to symbols.) I went back to v2.2.4 in SU2017 and repeatedly called #name
on a module object and got a different string object and id each time called. (Not very efficient.)
The same test in latest version returns the same object, with the same id, each time called.
I've not been running into it as I suppose I've not been using String
append ( <<
) much because of the gotchas like this.
I'm more inclined these days to use interpolation like:
LOAD_TAG = "#{Module.nesting[0].name}:#{File.basename(__FILE__)}"
... which itself creates a new string.
BTW ... the second assignment to OPT_KEY
does not need the .dup
as .gsub
makes the copy. (Verified in Ruby 2.7.7 with SketchUp 2023.)