[Glass] Why this closure fails to compile?

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Sun Nov 22 09:17:33 PST 2015


If you look at the CompileError the problem should be clearer (undefined 
symbol 'dic') (and yes you are probably tired:):

.        -> anArray( anArray( anArray( 1031, 109, 'undefined symbol', 
nil, 'dic')), '[ :node :dict | (node value isSymbol and: [ node value 
matchesRege...
..       -> a CompileError occurred (error 1001), compilation errors -- 
parameter 1 is error descriptor
(class)@ -> Array
(oop)@   -> 392425985
(size)@  -> 2
1@       -> anArray( anArray( 1031, 109, 'undefined symbol', nil, 'dic'))
2@       -> '[ :node :dict | (node value isSymbol and: [ node value 
matchesRegex: ''.*oldSelector.*'' ]) ifTrue: [ dic at: #''oldSelector'' 
put:...



You might want to wrap your #evaluate with something like the following:

[ '[ :node :dict |
(node value isSymbol and: [ node value matchesRegex: ''.*oldSelector.*'' ])
   ifTrue: [
     dic at: #''oldSelector'' put: node value.
     true ]
   ifFalse: [ false ]
]' evaluate ]
     on: CompileError
     do: [ :ex |
       | sourceWithErrors |
       sourceWithErrors := GsMethod
         _sourceWithErrors: ex errorDetails
         fromString:
           ((ex gsArguments at: 2) copyReplaceAll: String cr with: 
String lf).
       (GsMultiLineTextInteraction
         prompt: 'CompileError'
         template: sourceWithErrors) signal ]

To get a better error message ...

Dale

On 11/22/15 8:40 AM, Mariano Martinez Peck via Glass wrote:
> '[ :node :dict |
> (node value isSymbol and: [ node value matchesRegex: 
> ''.*oldSelector.*'' ])
>   ifTrue: [
>     dic at: #''oldSelector'' put: node value.
>     true ]
>   ifFalse: [ false ]
> ]' evaluate



More information about the Glass mailing list