Re: Safe index for Groovy 3

2016-11-08 Thread o...@ocs.cz
Hi there, > Any thoughts? Does it support properly "foo[null]", too? That aside, I would just again like to advocate for an, let's say, „full-safe“ mode, where one could set some switch (probably would need to be a compile-time one I guess) to get implicitly the „safe mode“ for _all_ exp

Re: Safe index for Groovy 3

2016-11-08 Thread Daniel Sun
Yeah, I like the idea too :) Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Safe-index-for-Groovy-3-tp5736558p5736562.html Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Safe index for Groovy 3

2016-11-08 Thread Guillaume Laforge
A few times I've wanted to have safe index. Sounds like a good idea. On Tue, Nov 8, 2016 at 5:08 PM, Daniel Sun wrote: > Hi all, > > The new parser supports safe index now, which is proposed by Paul > King > :) > > Here are some example code: > > assert null == null?[1]; > assert nul

Re: Safe index for Groovy 3

2016-11-08 Thread Daniel Sun
groovy-all-2.5.0-SNAPSHOT jar file used by groovy-parser is a bit outdated, the following usual code can not be executed too(but it can be executed by 2.4.7...), so the static complication test cases will be added later :) @CompileStatic int cs() { List a = [1, 2, 3] return a[0]; } cs();

Safe index for Groovy 3

2016-11-08 Thread Daniel Sun
Hi all, The new parser supports safe index now, which is proposed by Paul King :) Here are some example code: assert null == null?[1]; assert null == null?[1]?[1, 2]; assert null == null?[1]?[1, 2]?[1, 2, 3]; def a = null; assert null == a?[1, 2]; def f() {return null} assert null