Bad GSP Code Not Flagged

Hi,

I wrote this in a GSP page:

]]>


JetGroovy didn't complain in any way about this, but when I visit that page in the Grails application, a huge pile of exception traces is shown and the browser gets a 500 response.

In fact, I could not see what was the problem, but someon on the Grails mailing list spotted it. This is the correct code:

]]>



Randall Schulz

8 comments
Comment actions Permalink

I'm not sure this can be reported statically.

Eugene.

0
Comment actions Permalink

Is it not a syntax error?

0
Comment actions Permalink

Certainly not: assignment is a valid groovy expression, its result is the value of the right side.

0
Comment actions Permalink

I understand that, but Maps require key/value pairs, do they not? And is this notation not that of a literal Map?

Randlal Schulz

0
Comment actions Permalink

Groovy grammar allows to mix maps and lists in one literal. Not sure about the semantics though.

0
Comment actions Permalink

I mean map and list elements of course.

0
Comment actions Permalink

What on earth is a Map that contains elements that are not key/value pairs? How do you get at those elements? And if they are allowed, then why does Grails die such a horrible death when it counters such a beast?

Randall Schulz

0
Comment actions Permalink

Don't get me wrong, but this is another matter. Formal grammar of groovy does allow this, and therefore we cannot forbid it. If we make a joint decision to ban it, ok, it will be corrected. But before that this cannot be syntax error

0

Please sign in to leave a comment.