mirror of
https://github.com/apple/pkl.git
synced 2026-08-04 03:08:41 +02:00
Fix variable resolution of object body params (#1788)
Fixes a regression introduced in Pkl 0.32.
This commit is contained in:
@@ -523,6 +523,13 @@ public final class SymbolTable {
|
||||
if (scope instanceof LexicalScope lex) {
|
||||
if (shouldSkip && !(scope instanceof ForGeneratorScope)) {
|
||||
if (scope instanceof ObjectScope objectScope && objectScope.hasParams()) {
|
||||
// skipping the object scope should now see the object body params, because the params
|
||||
// are one level higher than the body itself.
|
||||
var result = fun.apply(objectScope, levelsUp);
|
||||
if (result instanceof Parameter parameter) {
|
||||
//noinspection unchecked
|
||||
return (R) new Parameter(parameter.slot(), parameter.levelsUp() - 1);
|
||||
}
|
||||
levelsUp++;
|
||||
}
|
||||
// An EagerGeneratorScope (for `when` predicates) skipped an ObjectScope.
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
foo = new Mapping {
|
||||
default { key ->
|
||||
for (idx, char in key.split("")) {
|
||||
["\(char)_\(idx)"] = "hi"
|
||||
}
|
||||
}
|
||||
["zzz"] {}
|
||||
}
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
foo = new Mapping {
|
||||
default { key ->
|
||||
when (key is String) {
|
||||
bar = key
|
||||
}
|
||||
}
|
||||
["x"] {}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
foo {
|
||||
["zzz"] {
|
||||
["z_0"] = "hi"
|
||||
["z_1"] = "hi"
|
||||
["z_2"] = "hi"
|
||||
}
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
foo {
|
||||
["x"] {
|
||||
bar = "x"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user