Fix: globbing--read extra storage from owner instead of receiver (#607)

This fixes an issue where a PklBugException is thrown when a globbed
read/import is amended.
This commit is contained in:
Daniel Chao
2024-08-05 10:27:50 -07:00
committed by Dan Chao
parent 2cd2712589
commit f4983c51be
6 changed files with 59 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ public final class ImportGlobMemberBodyNode extends ExpressionNode {
@Override
public Object executeGeneric(VirtualFrame frame) {
var mapping = VmUtils.getObjectReceiver(frame);
var mapping = VmUtils.getOwner(frame);
var path = (String) VmUtils.getMemberKey(frame);
return importModule(mapping, path);
}

View File

@@ -33,7 +33,7 @@ public class ReadGlobMemberBodyNode extends ExpressionNode {
@Override
public Object executeGeneric(VirtualFrame frame) {
var mapping = VmUtils.getObjectReceiver(frame);
var mapping = VmUtils.getOwner(frame);
var path = (String) VmUtils.getMemberKey(frame);
return readResource(mapping, path);
}

View File

@@ -16,6 +16,16 @@ examples {
import*("../../input-helper/globtest/**.pkl").keys.toListing()
}
["amended"] {
(import*("../../input-helper/globtest/**.pkl")) {
[[true]] {
output {
renderer = new YamlRenderer {}
}
}
}.toMap().values.map((it) -> it.output.text).join("\n---\n")
}
["globstar then up one level"] {
import*("../../input-helper/globtest/**/../*.pkl").keys.toListing()
}

View File

@@ -8,6 +8,14 @@ examples {
read*("globtest/*.txt")
}
["amended"] {
(read*("../../input-helper/globtest/**.pkl")) {
[[true]] {
text = "hi"
}
}
}
["env:"] {
// doesn't match names that include slashes
read*("env:*")

View File

@@ -21,6 +21,21 @@ examples {
"../../input-helper/globtest/child/moduleC.pkl"
}
}
["amended"] {
"""
{}
---
name: moduleA
---
name: moduleB
---
name: child/moduleC
"""
}
["globstar then up one level"] {
new {
"../../input-helper/globtest/child/../module with [weird] ~!characters.pkl"

View File

@@ -50,6 +50,30 @@ examples {
}
}
}
["amended"] {
new {
["../../input-helper/globtest/module with [weird] ~!characters.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/module%20with%20%5Bweird%5D%20~!characters.pkl"
text = "hi"
base64 = ""
}
["../../input-helper/globtest/moduleA.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/moduleA.pkl"
text = "hi"
base64 = "bmFtZSA9ICJtb2R1bGVBIgo="
}
["../../input-helper/globtest/moduleB.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/moduleB.pkl"
text = "hi"
base64 = "bmFtZSA9ICJtb2R1bGVCIgo="
}
["../../input-helper/globtest/child/moduleC.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/child/moduleC.pkl"
text = "hi"
base64 = "bmFtZSA9ICJjaGlsZC9tb2R1bGVDIgo="
}
}
}
["env:"] {
new {
["env:NAME1"] = "value1"