antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
956 stars 231 forks source link

The i and i0 just work in anonymous function but not named function #162

Closed suemi994 closed 6 years ago

suemi994 commented 8 years ago

The case is below:

saveField(f)::=<<
prep.set<f.type;format="capitalized">(<i>+1,<fieldValue(type=f.type,real={o.<f.name>})>);
>>

<fields:saveField();separator="\n">

It will report that not a visible attribute i, but when I change my code to:

saveField(f,index)::=<<
prep.set<f.type;format="capitalized">(<index>+1,<fieldValue(type=f.type,real={o.<f.name>})>);
>>
<fields:{f|<saveField(f,i)>};separator="\n">

It works!

So is it the intention of your design to make the i and i0 not visible in named function scope or it's just a bug?

parrt commented 6 years ago

Yep, i/i0 only work in the {...} block.