[Parse] Skip ahead if seeing any error while parsing list.

If we found any error in a list, in most cases, we cannot expect that the
following tokens could construct a valid element. Skip them, instead of trying
to parse them as the next element. This significally reduces bogus diagnostics.

Bailout if seeing tok::eof or token that can never start a element, after
parsing an element. This silences superfluous "expected ',' separator" error,
or misleading expected declaration error. What we should emit is
"expected ')' in expression list, or "expected '}' in struct".
This commit is contained in:
Rintaro Ishizaki
2016-10-06 13:16:34 +09:00
parent 7085e2a36c
commit f70d2d9e1c
14 changed files with 76 additions and 92 deletions

View File

@@ -308,7 +308,7 @@ case (_?)?: break
// <rdar://problem/20365753> Bogus diagnostic "refutable pattern match can fail"
let (responseObject: Int?) = op1
// expected-error @-1 2 {{expected ',' separator}} {{25-25=,}} {{25-25=,}}
// expected-error @-1 {{expected ',' separator}} {{25-25=,}}
// expected-error @-2 {{expected pattern}}