Fix reflect crash on modules using glob imports (#1816)

This excludes glob imports when creating a module's mirror
This commit is contained in:
Sergio Salvi
2026-08-25 12:04:45 -07:00
committed by GitHub
parent ae9160df51
commit a90eb74c2d
4 changed files with 23 additions and 2 deletions
@@ -0,0 +1,13 @@
import "pkl:reflect"
import* "../../input-helper/globtest/child/*.pkl" as globbed
// regression test for VmTyped.getImports()
// `member.isImport()` is true for glob imports too, so reflecting a module that
// uses `import*` previously threw ClassCastException when casting the glob
// import's body to ImportNode.
// Glob imports resolve to a mapping rather than a module type, so they are
// excluded from `imports` (which only reports regular imports).
res = reflect.Module(module).imports
// the glob import itself still works
globbedKeys = globbed.keys.toListing()
@@ -0,0 +1,4 @@
res = Map("reflect", "pkl:reflect")
globbedKeys {
"../../input-helper/globtest/child/moduleC.pkl"
}