cue/parser: use named error return in ParseExpr to fix error loss on bail-out
ParseExpr used unnamed return values, so the deferred recovery from
the "too many errors" panic could not propagate errors back to the
caller. This caused ParseExpr to return nil error for inputs with
enough scanner errors (e.g. invalid UTF-8) to trigger the bail-out,
even though ParseFile correctly rejected the same inputs.
Use a named error return, matching ParseFile's existing pattern.
It looks like ParseExpr has always had this bug,
as it has had this error recovery mechanism since day one
while never using a named return parameter for err.
Found via fuzzing.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: If7ccd6c5e85aa89fa3e8e98dd22c73af7a7b01c2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235294
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>