Scoping bug?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Scoping bug?

Chris Nokleberg
<#assign foo><#list 1 .. 4 as x>****</#list></#assign>
${foo}

Caught exception of type java.lang.IllegalArgumentException:
The variable x is not declared here.

This works in 2.3.8, but not in SVN. FWIW I also had some redefinition
errors in the SVN build (inner loop using same loop variable). I
understand this is intentional, but it is kind of annoying
nonetheless.

Thanks,
Chris

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Scoping bug?

Attila Szegedi
I tried looking into this, but it seems to be affecting the scoping  
mechanism that Jonathan fully rewrote for 2.4, and I don't really  
understand it at the moment. So I'd rather not touch it.

Jonathan, if you're around, you could try looking into it. It is trivially  
reproducible and apparently breaks every loop, rendering 2.4 quite  
unusable...

Attila.

On Mon, 09 Oct 2006 00:33:48 +0200, Chris Nokleberg <[hidden email]>  
wrote:

> <#assign foo><#list 1 .. 4 as x>****</#list></#assign>
> ${foo}
>
> Caught exception of type java.lang.IllegalArgumentException:
> The variable x is not declared here.
>
> This works in 2.3.8, but not in SVN. FWIW I also had some redefinition
> errors in the SVN build (inner loop using same loop variable). I
> understand this is intentional, but it is kind of annoying
> nonetheless.
>
> Thanks,
> Chris
>

--
home: http://www.szegedi.org
weblog: http://constc.blogspot.com

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Scoping bug?

revusky
On 1/12/07, Attila Szegedi <[hidden email]> wrote:
> I tried looking into this, but it seems to be affecting the scoping
> mechanism that Jonathan fully rewrote for 2.4, and I don't really
> understand it at the moment. So I'd rather not touch it.
>
> Jonathan, if you're around, you could try looking into it. It is trivially
> reproducible and apparently breaks every loop, rendering 2.4 quite
> unusable...

I've been very quiet recently, but I am reading the list. I'll have a
look at this.

JR

>
> Attila.
>
> On Mon, 09 Oct 2006 00:33:48 +0200, Chris Nokleberg <[hidden email]>
> wrote:
>
> > <#assign foo><#list 1 .. 4 as x>****</#list></#assign>
> > ${foo}
> >
> > Caught exception of type java.lang.IllegalArgumentException:
> > The variable x is not declared here.
> >
> > This works in 2.3.8, but not in SVN. FWIW I also had some redefinition
> > errors in the SVN build (inner loop using same loop variable). I
> > understand this is intentional, but it is kind of annoying
> > nonetheless.
> >
> > Thanks,
> > Chris
> >
>
> --
> home: http://www.szegedi.org
> weblog: http://constc.blogspot.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Scoping bug?

revusky
In reply to this post by Attila Szegedi
On 1/12/07, Attila Szegedi <[hidden email]> wrote:
> I tried looking into this, but it seems to be affecting the scoping
> mechanism that Jonathan fully rewrote for 2.4, and I don't really
> understand it at the moment. So I'd rather not touch it.

Well, it's not as rewritten as I intend it to be (eventually), it's
kind of stalled in the middle of a full rewrite.

>
> Jonathan, if you're around, you could try looking into it. It is trivially
> reproducible and apparently breaks every loop, rendering 2.4 quite
> unusable...

It didn't break every loop. It just broke loops that occurred within a
block assignment (which is pretty bad, I'll grant.) That was why it
wasn't immediately obvious, since I guess our unit tests do not
include a loop within a block assignment.

If you're wondering why it only happened within a block assignment,
the reason is that the postParseCleanup() method in
BlockAssignment.java did not call its super method as it is supposed
to do. And this meant, in effect that the postParseCleanup() methods
of nested blocks within that block assignment were not getting called.
(The base postParseCleanup() method was waht called the hook
recursively in the nested sub-blocks.)

And it was precisely within the postParseCleanup() hook that I added
the snippet of code whereby the loop index variable and things like
i_has_next and so on were tagged as being "defined" within the loop.
Adding it to that postParseCleanup hook is a bit kludgy and the whole
thing needs to be refactored quite a bit further.

The basic idea of the new scheme is that a tools API should now know,
at parse-time, which variables are defined in which scopes, more along
the lines of what a debugger for the java language "knows". This is
not currently the case really. This should be able to interact with
tools like IDE's and debuggers and whatnot. In fact, I suspect that
this whole refactoring I undertook last summer and then somehow
drifted away from is necessary to make FM more tool-friendly.

The other aspect of this is that, even creating all this new
infrastructure, it is not obvious that anybody is going to come out of
the woodwork and write cool tools that leverage that. Especially if it
is (as it is currently) undocumented, but... we'll see what we can do.
Off and on, I get a bit interested in trying to do something with
FreeMarker. OTOH, I have no idea how much time i'll be devoting to
this in the coming months...

JR

I

>
> Attila.
>
> On Mon, 09 Oct 2006 00:33:48 +0200, Chris Nokleberg <[hidden email]>
> wrote:
>
> > <#assign foo><#list 1 .. 4 as x>****</#list></#assign>
> > ${foo}
> >
> > Caught exception of type java.lang.IllegalArgumentException:
> > The variable x is not declared here.
> >
> > This works in 2.3.8, but not in SVN. FWIW I also had some redefinition
> > errors in the SVN build (inner loop using same loop variable). I
> > understand this is intentional, but it is kind of annoying
> > nonetheless.
> >
> > Thanks,
> > Chris
> >
>
> --
> home: http://www.szegedi.org
> weblog: http://constc.blogspot.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel