internal/core/runtime: validate imports in package-less files too master
Back in 2021, the patch https://cue-review.googlesource.com/c/cue/+/8925 fixed the bug at https://cuelang.org/issue/736 where a `cue eval` of CUE files belonging to a package could resolve references declared in files with an anonymous package. However, the fix went too far; it also removed the use of resolveFile for CUE files belonging to anonymous packages. resolveFile turns out to be responsible for reporting various errors relating to imports, such as them being unused, unknown in std, or redeclaring fields. Since none of that relates to resolving references between CUE files, tweak the logic so that resolveFile runs for anonymous package files. Given that the original patch from 2021 added tests that still pass, and we just added test that lock in the behavior for import errors on files with named and anonymous package clauses, this seems fine. The logic around "resolve files" should be cleaned up in the future, which is already tracked with TODOs in the runtime and compile packages. Fixes #1850. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I0e7ad266db7bd839784439c2cd4d13df29256c45 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214605 Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Matthew Sackman <matthew@cue.works>