'val' should not be legal in basic for loops. #419

Closed
lombokissues opened this Issue Jul 14, 2015 · 6 comments

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 346)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Feb 14, 2012 at 01:37 UTC

This actually works and is really cool:

for (val x = 5, y = ""; ; ) {
}

Unfortunately, while it's cool that that works, we CANNOT delombok it. Practically speaking having final variables declared inside a basic for loop's line has no real use cases, either.

The easiest solution is to just disallow use of 'val' here. We won't, of course, mess with using 'val' in foreach loops!

NB: We should also test how delombok treats:

val x = 5, y = "";

as a variable declaration. Correct treatment is allowing it and splitting it into two var decls which I'm fairly sure will happen, but, we should add a test.

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Feb 14, 2012 at 01:37 UTC

NB: Someone sent me a message about this (twitter, google+, google groups? I can't remember). Anyway, all credit to him for figuring this one out :)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Feb 15, 2012 at 03:36 UTC

Fixed; will be in whatever's after 0.10.8.

@lombokissues lombokissues added this to the 0.10.9 milestone Jul 14, 2015
@lombokissues
Collaborator

๐Ÿ‘ค askoning ย  ๐Ÿ•— Mar 02, 2012 at 19:37 UTC

@lombokissues
Collaborator

๐Ÿ‘ค enrique.dacostacambio ย  ๐Ÿ•— Mar 17, 2015 at 06:55 UTC

Would it make sense to enforce that all variables are of the same type? By explicitly checking the types of the expressions or by using the type of the expression if the first variable?

@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment