New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

Projects
None yet
1 participant
@lombokissues
Collaborator

lombokissues commented Jul 14, 2015

Migrated from Google Code (issue 346)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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.

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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 :)

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 reinierz   🕗 Feb 15, 2012 at 03:36 UTC

Fixed; will be in whatever's after 0.10.8.

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 askoning   🕗 Mar 02, 2012 at 19:37 UTC

Collaborator

lombokissues commented Jul 14, 2015

👤 askoning   🕗 Mar 02, 2012 at 19:37 UTC

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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?

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

End of migration

Collaborator

lombokissues commented Jul 14, 2015

End of migration

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