Skip to content

Commit

Permalink
cue/load: set the absolute file name when setting source
Browse files Browse the repository at this point in the history
This means that when the file is decoded, the `internal/encoding.NewDecoder`
logic can find it, even though `internal/encoding.Config` doesn't
contain a directory field to interpret relative file paths.

This fixes a test failure that happens when the modules experiment
flag is enabled by default.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Ia606ce2dc0fca816f3986c24fda96041862b0297
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194830
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
rogpeppe committed May 16, 2024
1 parent b57a20a commit 4a27795
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cue/load/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func setFileSource(cfg *Config, f *build.File) error {
}
if !filepath.IsAbs(fullPath) {
fullPath = filepath.Join(cfg.Dir, fullPath)
// Ensure that encoding.NewDecoder will work correctly.
f.Filename = fullPath
}
if fi := cfg.fileSystem.getOverlay(fullPath); fi != nil {
if fi.file != nil {
Expand Down

0 comments on commit 4a27795

Please sign in to comment.