9 Apr 2005 15:46
Re: proposed rule: no assignments to literals
Definitely! Whether we can do this inside the Antlr grammar, or we add a validation check to the Groovy AST verifier (which has a few checks in it already) I don't much mind, but we definitely need to outlaw these examples. On 9 Apr 2005, at 13:21, Dierk Koenig wrote: > Currently Groovy allows > > 'aaa' = 'bbb' > "aaa" = "bbb" > /aaa/ = /bbb/ > null = new Object() > 0 = 1 > 0f = 1f > \u0000 = \u0001 > > // questionable > [] = new Object() > [:] = new Object() > 1..2 = new Object() > > this makes it harder to write safe boolean tests, e.g. > if (null == a) > instead of > if (a == null) > to mitigate the risk of a missing =, e.g > if (null = a) > should not compile. > > I think this should be possible by changing > only the grammar file. > > cheers > Mittie > > James ------- http://radio.weblogs.com/0112098/
RSS Feed