SPICE-0020: Deferred, type-safe references (#1354)

This commit is contained in:
Jen Basch
2026-06-23 15:26:06 +02:00
committed by GitHub
parent b3015a09cc
commit 8a43e51e6b
83 changed files with 2573 additions and 226 deletions
@@ -0,0 +1 @@
foo: String
@@ -0,0 +1,7 @@
open module ReferencedModuleWithOutputOverride
foo: String
hidden output: ModuleOutput = new {
text = foo
}
@@ -0,0 +1,134 @@
import "pkl:math"
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String =
let (data = reference.getData())
let (root = if (data is Resource) data.name else data.toString())
let (
path =
reference
.getPath()
.map((elem) -> if (elem.isProperty) ".\(elem.property)" else "[\(elem.key)]")
)
"${\(root)\(path.join(""))}"
}
local const d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
abstract class Resource {
name: String
hidden fixed $: Ref<Resource>
}
class A extends Resource {
id: String
hidden outputs: AProperties
hidden fixed $: Ref<A> = ref.Reference(d, A, this)
}
/// Test doc comment
class AProperties {
foo: Int
someMapping: Mapping<String, Int?>
someMap: Map<MapKey, Int>
someListing: Listing<Int>
someList: List<Int>
nonInt: String
}
class B extends Resource {
id: String
hidden outputs: BProperties
hidden fixed $: Ref<B> = ref.Reference(d, B, this)
}
class BProperties {
foo: String
someMapping: Mapping<String, String?>
someMap: Map<MapKey, String>
someListing: Listing<String>
someList: List<String>
nonString: Int
}
class MapKey {
k: Int
function toString(): String = "key:\(k)"
}
class K {
aId: String | *Ref<String>?
bId: String | *Ref<String>?
aProperties: AProperties | *Ref<AProperties>?
bProperties: BProperties | *Ref<BProperties>?
aValues: Listing<Int | Ref<Int?>>?
bValues: Listing<String | Ref<String?>>?
splitUnion: Ref<Listing<String> | Listing<Int>>?
}
a: A = new {
name = "a"
id = "some-a-value"
}
b: B = new {
name = "b"
id = "some-b-value"
}
aOrB: A | B = a
aRef: Ref<A> = a.$
bRef: Ref<B> = b.$
unknownRef: Ref<A | B> = aRef
unknownRef2: Ref<A> | Ref<B> = aRef
unknownRef3: Ref<B | A> = aOrB.$
k: K = new {
aId = aRef.id
bId = bRef.id
aProperties = aRef.outputs
bProperties = bRef.outputs
aValues {
aRef.outputs.foo
aRef.outputs.someMapping["key"]
aRef.outputs.someMap[new MapKey { k = 123 }]
aRef.outputs.someListing[0]
aRef.outputs.someList[math.maxInt]
bRef.outputs.nonString
}
bValues {
bRef.outputs.foo
bRef.outputs.someMapping["key"]
bRef.outputs.someMap[new MapKey { k = 123 }]
bRef.outputs.someListing[0]
bRef.outputs.someList[math.maxInt]
aRef.outputs.nonInt
}
}
j: K = new {
local aRef2 = unknownRef as Ref<A>
aProperties = aRef2.outputs
splitUnion = unknownRef.outputs.someListing
}
refInterpolation = "\(aRef.outputs.someListing[1])"
kInterpolation = "\(k)"
aValuesJoined = k.aValues.join("\n").replaceAll(Regex("@[a-z0-9]+"), "@<addr>")
// ensure that type arguments that are unions are handled correctly
typeArgs = ref.Reference(d, TypeHolder, null).prop as Ref<Listing<Number | Boolean | String>>
class TypeHolder {
prop: Listing<String | Boolean | Number>
}
output {
renderer {
converters {
[ref.Reference] = (it) -> it.toString()
}
}
}
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
test = ref.Reference(d, String, "") as Ref<Int>
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
test = ref.Reference(d, String, "") as Ref<Listing<String(true)>>
@@ -0,0 +1,12 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
test = ref.Reference(d, String, "") as Ref<Alias1?>
typealias Alias1 = Int | Alias2?
typealias Alias2 = String(length < 5)
@@ -0,0 +1,12 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
typealias RefAlias1 = ref.Reference<D, Alias1?>
local d: D = new {}
test = ref.Reference(d, String, "") as RefAlias1
typealias Alias1 = Int | Alias2?
typealias Alias2 = String(length < 5)
@@ -0,0 +1,8 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, Mapping, "").default
@@ -0,0 +1,8 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, Listing, "").default
@@ -0,0 +1,8 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, Dynamic, "").default
@@ -0,0 +1,10 @@
import "pkl:ref"
import ".../input-helper/errors/ReferencedModule.pkl"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, ReferencedModule.getClass(), "").output
@@ -0,0 +1,10 @@
import "pkl:ref"
import ".../input-helper/errors/ReferencedModuleWithOutputOverride.pkl"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, ReferencedModuleWithOutputOverride.getClass(), "").output
@@ -0,0 +1,12 @@
import "pkl:ref"
import ".../input-helper/errors/ReferencedModuleWithOutputOverride.pkl"
class ModuleSubclass extends ReferencedModuleWithOutputOverride
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, ModuleSubclass, "").output
@@ -0,0 +1,12 @@
import "pkl:ref"
class A {
foo: String | Int | Boolean
}
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
test = ref.Reference(d, A, "").foo as ref.Reference<D, Int | Boolean>
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
test = ref.Reference(d, String, "") as Ref<Boolean | Int>
@@ -0,0 +1,15 @@
import "pkl:ref"
class A {
foo: String | Int | Boolean
}
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
local test = ref.Reference(d, A, "").foo
testInterpolation = "test:\(test)"
// this tests that the interpolation appears in the output when referenceToString throws
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
test = ref.Reference(d, String, "") as Ref<Listing<String>>
@@ -0,0 +1,12 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
test = ref.Reference(d, String, "") as Ref<Alias1?>
typealias Alias1 = Int | Alias2?
typealias Alias2 = Boolean
@@ -0,0 +1,14 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
class D2 extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d2: D2 = new {}
test = ref.Reference(d2, String, "") as Ref<String>
@@ -0,0 +1,13 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
class A {
b: String
}
test = ref.Reference(d, String, new A {}).c
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
test = ref.Reference(d, List, List())["hi"]
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
test = ref.Reference(d, String, "") as Ref<String(true)>
@@ -0,0 +1,9 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
test = ref.Reference(d, String, "") as Ref<String(true) | Int>
@@ -0,0 +1,60 @@
a {
name = "a"
id = "some-a-value"
}
b {
name = "b"
id = "some-b-value"
}
aOrB {
name = "a"
id = "some-a-value"
}
aRef = "${a}"
bRef = "${b}"
unknownRef = "${a}"
unknownRef2 = "${a}"
unknownRef3 = "${a}"
k {
aId = "${a.id}"
bId = "${b.id}"
aProperties = "${a.outputs}"
bProperties = "${b.outputs}"
aValues {
"${a.outputs.foo}"
"${a.outputs.someMapping[key]}"
"${a.outputs.someMap[key:123]}"
"${a.outputs.someListing[0]}"
"${a.outputs.someList[9223372036854775807]}"
"${b.outputs.nonString}"
}
bValues {
"${b.outputs.foo}"
"${b.outputs.someMapping[key]}"
"${b.outputs.someMap[key:123]}"
"${b.outputs.someListing[0]}"
"${b.outputs.someList[9223372036854775807]}"
"${a.outputs.nonInt}"
}
splitUnion = null
}
j {
aId = null
bId = null
aProperties = "${a.outputs}"
bProperties = null
aValues = null
bValues = null
splitUnion = "${a.outputs.someListing}"
}
refInterpolation = "${a.outputs.someListing[1]}"
kInterpolation = "new K { aId = Reference(new D {}, String, new A { name = \"a\"; id = \"some-a-value\" }).id; bId = Reference(new D {}, String, new B { name = \"b\"; id = \"some-b-value\" }).id; aProperties = Reference(new D {}, reference#AProperties, new A { name = \"a\"; id = \"some-a-value\" }).outputs; bProperties = Reference(new D {}, reference#BProperties, new B { name = \"b\"; id = \"some-b-value\" }).outputs; aValues { Reference(new D {}, Int, new A { name = \"a\"; id = \"some-a-value\" }).outputs.foo; Reference(new D {}, Int | Null, new A { name = \"a\"; id = \"some-a-value\" }).outputs.someMapping[\"key\"]; Reference(new D {}, Int, new A { name = \"a\"; id = \"some-a-value\" }).outputs.someMap[new MapKey { k = 123 }]; Reference(new D {}, Int, new A { name = \"a\"; id = \"some-a-value\" }).outputs.someListing[0]; Reference(new D {}, Int, new A { name = \"a\"; id = \"some-a-value\" }).outputs.someList[9223372036854775807]; Reference(new D {}, Int, new B { name = \"b\"; id = \"some-b-value\" }).outputs.nonString }; bValues { Reference(new D {}, String, new B { name = \"b\"; id = \"some-b-value\" }).outputs.foo; Reference(new D {}, Null | String, new B { name = \"b\"; id = \"some-b-value\" }).outputs.someMapping[\"key\"]; Reference(new D {}, String, new B { name = \"b\"; id = \"some-b-value\" }).outputs.someMap[new MapKey { k = 123 }]; Reference(new D {}, String, new B { name = \"b\"; id = \"some-b-value\" }).outputs.someListing[0]; Reference(new D {}, String, new B { name = \"b\"; id = \"some-b-value\" }).outputs.someList[9223372036854775807]; Reference(new D {}, String, new A { name = \"a\"; id = \"some-a-value\" }).outputs.nonInt }; splitUnion = null }"
aValuesJoined = """
org.pkl.core.runtime.VmReference@<addr>
org.pkl.core.runtime.VmReference@<addr>
org.pkl.core.runtime.VmReference@<addr>
org.pkl.core.runtime.VmReference@<addr>
org.pkl.core.runtime.VmReference@<addr>
org.pkl.core.runtime.VmReference@<addr>
"""
typeArgs = "${null.prop}"
@@ -20,6 +20,7 @@ pkl:pklbinary
pkl:platform
pkl:Project
pkl:protobuf
pkl:ref
pkl:reflect
pkl:release
pkl:semver
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference1#D, Int>`, but got type `pkl.ref#Reference<reference1#D, String>`.
Value: Reference(new D {}, String, "")
x | typealias Ref<T> = ref.Reference<D, T>
^^^^^^^^^^^^^^^^^^^
at reference1#test (file:///$snippetsDir/input/errors/reference1.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
`Reference` referent type argument may not include type constraints.
x | test = ref.Reference(d, String, "") as Ref<Listing<String(true)>>
^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference10#test (file:///$snippetsDir/input/errors/reference10.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
`Reference` referent type argument may not include type constraints.
x | test = ref.Reference(d, String, "") as Ref<Alias1?>
^^^^^^^^^^^^
at reference11#test (file:///$snippetsDir/input/errors/reference11.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
`Reference` referent type argument may not include type constraints.
x | typealias RefAlias1 = ref.Reference<D, Alias1?>
^^^^^^^^^^^^^^^^^^^^^^^^^
at reference12#RefAlias1 (file:///$snippetsDir/input/errors/reference12.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `default` in object of type `pkl.ref#Reference<reference13#D, Mapping<unknown, unknown>>`.
x | test = ref.Reference(d, Mapping, "").default
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference13#test (file:///$snippetsDir/input/errors/reference13.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `default` in object of type `pkl.ref#Reference<reference14#D, Listing<unknown>>`.
x | test = ref.Reference(d, Listing, "").default
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference14#test (file:///$snippetsDir/input/errors/reference14.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `default` in object of type `pkl.ref#Reference<reference15#D, Dynamic>`.
x | test = ref.Reference(d, Dynamic, "").default
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference15#test (file:///$snippetsDir/input/errors/reference15.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `output` in object of type `pkl.ref#Reference<reference16#D, ReferencedModule>`.
xx | test = ref.Reference(d, ReferencedModule.getClass(), "").output
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference16#test (file:///$snippetsDir/input/errors/reference16.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `output` in object of type `pkl.ref#Reference<reference17#D, ReferencedModuleWithOutputOverride>`.
xx | test = ref.Reference(d, ReferencedModuleWithOutputOverride.getClass(), "").output
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference17#test (file:///$snippetsDir/input/errors/reference17.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `output` in object of type `pkl.ref#Reference<reference18#D, reference18#ModuleSubclass>`.
xx | test = ref.Reference(d, ModuleSubclass, "").output
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference18#test (file:///$snippetsDir/input/errors/reference18.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference19#D, Int | Boolean>`, but got type `pkl.ref#Reference<reference19#D, Boolean | Int | String>`.
Value: Reference(new D {}, Boolean | Int | String, "").foo
xx | test = ref.Reference(d, A, "").foo as ref.Reference<D, Int | Boolean>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference19#test (file:///$snippetsDir/input/errors/reference19.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference2#D, Boolean | Int>`, but got type `pkl.ref#Reference<reference2#D, String>`.
Value: Reference(new D {}, String, "")
x | typealias Ref<T> = ref.Reference<D, T>
^^^^^^^^^^^^^^^^^^^
at reference2#test (file:///$snippetsDir/input/errors/reference2.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,22 @@
–– Pkl Error ––
not supported
x | function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
^^^^^^^^^^^^^^^^^^^^^^
at reference20#D.renderReference (file:///$snippetsDir/input/errors/reference20.pkl)
xxx | function toString(): String = getDomain().renderReference(this)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.ref#Reference.toString (pkl:ref)
xx | testInterpolation = "test:\(test)"
^^^^^^^
at reference20#testInterpolation (file:///$snippetsDir/input/errors/reference20.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference3#D, Listing<String>>`, but got type `pkl.ref#Reference<reference3#D, String>`.
Value: Reference(new D {}, String, "")
x | typealias Ref<T> = ref.Reference<D, T>
^^^^^^^^^^^^^^^^^^^
at reference3#test (file:///$snippetsDir/input/errors/reference3.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference4#D, reference4#Alias1?>`, but got type `pkl.ref#Reference<reference4#D, String>`.
Value: Reference(new D {}, String, "")
x | typealias Ref<T> = ref.Reference<D, T>
^^^^^^^^^^^^^^^^^^^
at reference4#test (file:///$snippetsDir/input/errors/reference4.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,15 @@
–– Pkl Error ––
Expected value of type `pkl.ref#Reference<reference5#D, String>`, but got type `pkl.ref#Reference<reference5#D2, String>`.
Value: Reference(new D2 {}, String, "")
x | typealias Ref<T> = ref.Reference<D, T>
^^^^^^^^^^^^^^^^^^^
at reference5#test (file:///$snippetsDir/input/errors/reference5.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
Cannot find property `c` in object of type `pkl.ref#Reference<reference6#D, String>`.
xx | test = ref.Reference(d, String, new A {}).c
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference6#test (file:///$snippetsDir/input/errors/reference6.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,16 @@
–– Pkl Error ––
Operator `[]` is not defined for operand types `pkl.ref#Reference<reference7#D, List<unknown>>` and `String`.
Left operand : Reference(new D {}, List<unknown>, List())
Right operand: "hi"
x | test = ref.Reference(d, List, List())["hi"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at reference7#test (file:///$snippetsDir/input/errors/reference7.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
`Reference` referent type argument may not include type constraints.
x | test = ref.Reference(d, String, "") as Ref<String(true)>
^^^^^^^^^^^^^^^^^
at reference8#test (file:///$snippetsDir/input/errors/reference8.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)
@@ -0,0 +1,14 @@
–– Pkl Error ––
`Reference` referent type argument may not include type constraints.
x | test = ref.Reference(d, String, "") as Ref<String(true) | Int>
^^^^^^^^^^^^^^^^^^^^^^^
at reference9#test (file:///$snippetsDir/input/errors/reference9.pkl)
xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)
xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
at pkl.base#Module.output.bytes (pkl:base)