Skip to content

Commit a36cc32

Browse files
committed
internal/mod/modpkgload: propagate CUE syntax error
When there's a syntax error reading CUE syntax, the error details were being hidden. This resulted in issue #3281. Using `%w` instead of `%v` fixes this. Fixes #3281. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I43e49cde84319de9a20a395eea46664831e8a470 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197984 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent af808c3 commit a36cc32

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# When there's a syntax error encountered at an early
2+
# stage of processing, the error message should
3+
# point to the place in the file where the error was
4+
# encountered.
5+
6+
! exec cue eval invalid.cue
7+
stderr invalid.cue:3:
8+
-- cue.mod/module.cue --
9+
module: "test.example"
10+
language: version: "v0.9.0"
11+
12+
-- invalid.cue --
13+
package blah
14+
15+
self: bad )
16+
syntax

cue/load/instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func loadPackages(
205205
}
206206
syntax, err := cfg.fileSystem.getCUESyntax(f)
207207
if err != nil {
208-
return nil, fmt.Errorf("cannot get syntax for %q: %v", f.Filename, err)
208+
return nil, fmt.Errorf("cannot get syntax for %q: %w", f.Filename, err)
209209
}
210210
for _, imp := range syntax.Imports {
211211
pkgPath, err := strconv.Unquote(imp.Path.Value)

0 commit comments

Comments
 (0)