mirror of
https://github.com/apple/pkl.git
synced 2026-03-17 23:03:54 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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:*")
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user