mirror of
https://github.com/apple/pkl.git
synced 2026-09-13 13:21:47 +02:00
Fix replacements of types nested within nested constraints (#1731)
Also, adjust tests
This commit is contained in:
+16
-2
@@ -1,3 +1,17 @@
|
||||
typealias MyList<T> = List(this[0] is T)
|
||||
import "pkl:test"
|
||||
|
||||
foo: MyList<Int> = List("uh oh")
|
||||
typealias MyList<T> = List(this[0] is T)
|
||||
typealias MyList2<T> = List((this[0] as T) != null)
|
||||
typealias MyList3<T> = List((this[0] is Any(this is T)))
|
||||
typealias MyList4<T> = List((this[0] is T(!(this is T))))
|
||||
typealias MyList5<T> = List((this[0] is T(true)))
|
||||
typealias MyList6<T> = List(this[0] is T?)
|
||||
|
||||
local foo = List("uh oh")
|
||||
|
||||
res = test.catch(() -> foo as MyList<Int>)
|
||||
res2 = test.catch(() -> foo as MyList2<Int>)
|
||||
res3 = test.catch(() -> foo as MyList3<Int>)
|
||||
res4 = test.catch(() -> foo as MyList4<String>)
|
||||
res5 = test.catch(() -> foo as MyList5<Int>)
|
||||
res6 = test.catch(() -> foo as MyList6<Int>)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
–– Pkl Error ––
|
||||
Type constraint `this[0] is T` violated.
|
||||
Value: List("uh oh")
|
||||
|
||||
this[0] is T
|
||||
│ │ │
|
||||
│ │ false
|
||||
│ "uh oh"
|
||||
List("uh oh")
|
||||
|
||||
x | typealias MyList<T> = List(this[0] is T)
|
||||
^^^^^^^^^^^^
|
||||
at typeAliasConstraint3#foo (file:///$snippetsDir/input/types/typeAliasConstraint3.pkl)
|
||||
|
||||
x | foo: MyList<Int> = List("uh oh")
|
||||
^^^^^^^^^^^^^
|
||||
at typeAliasConstraint3#foo (file:///$snippetsDir/input/types/typeAliasConstraint3.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)
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
res = "Type constraint `this[0] is T` violated. Value: List(\"uh oh\")"
|
||||
res2 = "Expected value of type `Int`, but got type `String`. Value: \"uh oh\""
|
||||
res3 = "Type constraint `this[0] is Any(this is T)` violated. Value: \"u\""
|
||||
res4 = "Type constraint `this[0] is T(!(this is T))` violated. Value: \"u\""
|
||||
res5 = "Type constraint `this[0] is T(true)` violated. Value: List(\"uh oh\")"
|
||||
res6 = "Type constraint `this[0] is T?` violated. Value: List(\"uh oh\")"
|
||||
Reference in New Issue
Block a user