LVTI diagnostics anomaly?
maurizio.cimadamore at oracle.com
Tue Sep 19 20:09:01 UTC 2017
In the first case, 's' is a local variable in the code; in the second
case, 's' is a field, which is why it's not allowed. Does it makes sense?
I understand that, looking at the plain diagnostic output w/o also
looking at the source might be surprising, but I think in a real world
case it would be clear as to why it's not allowed?
Of course the 'not allowed' diagnostic can be improved an 'qualified' a
bit so that it includes some more context.
On 19/09/17 17:30, Stephan Janssen wrote:
> The LVTI diagnostics error messages have (according to me) an inconsistency.
> examples/LocalRedundantType.java:31: warning: Redundant type for local
> variable (replace explicit type with 'var'). String s = ""; ^ 1 warning
> The above makes a suggestion to replace the explicit type with 'var', which
> is great.
> However, VarNotAllowedHere.java mentions that the above
> var s = "";
> is not allowed, which confuses me.
> examples/VarNotAllowedHere.java:29: error: 'var' is not allowed here var s
> = ""; ^ 1 error
> Hopefully this helps?
More information about the amber-dev