From 4a27795456a14d58f3dce5a8e1fa1a59ec8b73e5 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Thu, 16 May 2024 11:43:18 +0100 Subject: [PATCH] cue/load: set the absolute file name when setting source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: Ia606ce2dc0fca816f3986c24fda96041862b0297 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194830 TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí --- cue/load/import.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cue/load/import.go b/cue/load/import.go index 33c09720911..c596e87fa4a 100644 --- a/cue/load/import.go +++ b/cue/load/import.go @@ -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 {