completion analysis and return, was Bugs

Robert Field robert.field at oracle.com
Tue Feb 3 16:26:34 UTC 2015


The goal of completion analysis is to determine if an input is incomplete 
(prompt is needed for more input),   where a unit of code ends if there are 
more than one on a line, and if the input needs a semicolon added. The gray 
area then is what to do for erroneous input. My decision was to fail-fast, 
so the user can send to declare() for error messages. This is clearly the 
right choice for lexical garbage. But in a case like this, it can result in 
no semicolon being added, and thus a poorer error message. So, I think I 
will shift to being more lenient. Additionally, I'm thinking, in declare(), 
return could be treated as the expression value, since this is what you 
want if you paste in a method body. Thoughts?

The reason the results are different is that given anything ending before 
the matching brace, parenthesis, or bracket is known to be incomplete, the 
insides are not looked at, except to match.

Thanks,
Robert



On February 3, 2015 4:07:27 AM "andrei.eremeev" <andrei.eremeev at oracle.com> 
wrote:

> And another thing.
> Return is not allowed in the top-level declaration, but completion
> analysis returns different values according whether a statement has braces.
>
> if (os == null) return null; <- UNKNOWN
> if (os == null) { return null; } <- COMPLETE
>
> Is it correct behavior for this code?
>
> Andrei Eremeev
>
> On 02/03/2015 11:56 AM, andrei.eremeev wrote:
> > Yes, thank you. The root cause of the problem is using labels in such
> > way:
> >    a : { for (int i = 0; i < 10; ++i) { break a;} }
> >
> > Andrei Eremeev
> >
> > On 02/02/2015 08:21 PM, Jonathan Gibbons wrote:
> >> On 02/02/2015 07:33 AM, andrei.eremeev wrote:
> >>> Hi REPL team,
> >>>
> >>> New REPL bugs related to completion analysis:
> >>> 1. assert true // Expected COMPLETE_WITH_SEMI, got COMPLETE.
> >>>
> >>> 2. switch (ch) case a: break; // Expected COMPLETE_WITH_SEMI, got
> >>> UNKNOWN.
> >>> "break" breaks the code.
> >>
> >> Andrei,
> >>
> >> Did you really mean what you typed in the example, with no '{' ?
> >> Doesn't seem like COMPLETE_WITH_SEMI to me.
> >>
> >> -- Jon
> >>
> >>>
> >>> 3. Statements without braces fail.
> >>> for(Object o : a) a; // expected [COMPLETE] but found [UNKNOWN]
> >>> As well as If constructions.
> >>>
> >>> 4. int path[], status: expected [COMPLETE_WITH_SEMI], but found
> >>> [DEFINITELY_INCOMPLETE]
> >>>
> >>> Andrei Eremeev
> >>
> >
>




More information about the kulla-dev mailing list