Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -371,7 +371,7 @@ private void writeClassName(VmValue value) {

VmClass clazz = value.getVmClass();
append("new ");
append(clazz.getSimpleName());
append(clazz.getDisplayName());
append(' ');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ examples {
"new Listing { 1; 2; 3 }"
"new Mapping { [\"Pigeon\"] = 42; [\"Barn Owl\"] = 21 }"
"new Dynamic { name = \"Pigeon\"; age = 42 }"
"new Person2 { name = \"Pigeon\"; age = 42 }"
"new any#Person2 { name = \"Pigeon\"; age = 42 }"
"null"
"null"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ res10 = "Cannot render value of type `Map` as Properties. Value: Map(\"name\", \
res11 = "Cannot render value of type `Listing` as Properties. Value: new Listing { \"pigeon\"; \"parrot\" }"
res12 = "Cannot render value of type `Mapping` as Properties. Value: new Mapping { [\"name\"] = ?; [\"age\"] = ? }"
res13 = "Cannot render value of type `Dynamic` as Properties. Value: new Dynamic { name = ?; age = ? }"
res14 = "Cannot render value of type `propertiesRenderer4#Person` as Properties. Value: new Person { name = ?; age = ? }"
res14 = "Cannot render value of type `propertiesRenderer4#Person` as Properties. Value: new propertiesRenderer4#Person { name = ?; age = ? }"
res15 = "Cannot render value of type `Pair` as Properties. Value: Pair(1, 2)"
res16 = "Cannot render value of type `Class` as Properties. Value: propertiesRenderer4#Person"
res17 = "Cannot render value of type `TypeAlias` as Properties. Value: propertiesRenderer4#Email"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ examples {
["annAOverrideB"] {
name = "annAOverrideB"
annotations {
"new MyAnn {}"
"new reflect4#MyAnn {}"
}
allAnnotations {
"new MyAnn {}"
"new reflect4#MyAnn {}"
"new Unlisted {}"
}
modifiers {}
Expand All @@ -128,10 +128,10 @@ examples {
["annAOverrideC"] {
name = "annAOverrideC"
annotations {
"new MyAnn {}"
"new reflect4#MyAnn {}"
}
allAnnotations {
"new MyAnn {}"
"new reflect4#MyAnn {}"
"new Unlisted {}"
}
modifiers {}
Expand All @@ -145,7 +145,7 @@ examples {
}
allAnnotations {
"new AlsoKnownAs { names { \"mergedAnnotations\" } }"
"new MyAnn {}"
"new reflect4#MyAnn {}"
"new Unlisted {}"
}
modifiers {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<age>42</age>
</pigeon2>
<res2>`xml.Element` is not supported here. Value: new Dynamic { _isXmlElement = true; name = &quot;pigeon2&quot;; attributes {}; isBlockF...</res2>
<res3>`xml.Inline` is not supported here. Value: new Inline { value { name = ?; age = ? } }</res3>
<res3>`xml.Inline` is not supported here. Value: new pkl.xml#Inline { value { name = ?; age = ? } }</res3>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ examples {
}
["invalid top level value"] {
"The top-level value of a YAML stream must have type `Listing`, `List`, or `Set`, but got type `Int`. Value: 5"
"The top-level value of a YAML stream must have type `Listing`, `List`, or `Set`, but got type `yamlRendererStream2#Foo`. Value: new Foo {}"
"The top-level value of a YAML stream must have type `Listing`, `List`, or `Set`, but got type `yamlRendererStream2#Foo`. Value: new yamlRendererStream2#Foo {}"
}
}
14 changes: 7 additions & 7 deletions pkl-core/src/test/files/LanguageSnippetTests/output/basic/as.pcf
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ examples {
"Expected value of type `Null`, but got type `List`. Value: List(1, 2, 3)"
"Expected value of type `Null`, but got type `Set`. Value: Set(1, 2, 3)"
"Expected value of type `Null`, but got type `Map`. Value: Map(1, \"one\", 2, \"two\", 3, \"three\")"
"Expected value of type `Null`, but got type `as#Base`. Value: new Base {}"
"Expected value of type `Null`, but got type `as#Derived`. Value: new Derived {}"
"Expected value of type `Null`, but got type `as#Base`. Value: new as#Base {}"
"Expected value of type `Null`, but got type `as#Derived`. Value: new as#Derived {}"
"Expected value of type `Null`, but got type `Mapping`. Value: new Mapping { [\"name\"] = \"Pigeon\"; [\"age\"] = 40 }"
"Expected value of type `Null`, but got type `Class`. Value: as#Base"
"Expected value of type `Null`, but got type `Listing`. Value: new Listing { null; null; \"Expected value of type `Null`, but got type `Strin..."
Expand All @@ -59,9 +59,9 @@ examples {
"Expected value of type `Int`, but got type `Map`. Value: Map(1, \"one\", 2, \"two\", 3, \"three\")"
"Expected value of type `Int`, but got `null`."
"Expected value of type `Int`, but got `null`."
"Expected value of type `Int`, but got type `as#Base`. Value: new Base {}"
"Expected value of type `Int`, but got type `as#Base`. Value: new as#Base {}"
"Expected value of type `Int`, but got type `Function1`. Value: new Function1 {}"
"Expected value of type `Int`, but got type `as#Derived`. Value: new Derived {}"
"Expected value of type `Int`, but got type `as#Derived`. Value: new as#Derived {}"
"Expected value of type `Int`, but got type `Mapping`. Value: new Mapping { [\"name\"] = \"Pigeon\"; [\"age\"] = 40 }"
"Expected value of type `Int`, but got type `Class`. Value: as#Base"
"Expected value of type `Int`, but got type `Listing`. Value: new Listing { 42; \"Expected value of type `Int`, but got type `String`. Value..."
Expand All @@ -83,8 +83,8 @@ examples {
"Expected value of type `as#Other`, but got type `Map`. Value: Map(1, \"one\", 2, \"two\", 3, \"three\")"
"Expected value of type `as#Other`, but got `null`."
"Expected value of type `as#Other`, but got `null`."
"Expected value of type `as#Other`, but got type `as#Base`. Value: new Base {}"
"Expected value of type `as#Other`, but got type `as#Derived`. Value: new Derived {}"
"Expected value of type `as#Other`, but got type `as#Base`. Value: new as#Base {}"
"Expected value of type `as#Other`, but got type `as#Derived`. Value: new as#Derived {}"
"Expected value of type `as#Other`, but got type `Mapping`. Value: new Mapping { [\"name\"] = \"Pigeon\"; [\"age\"] = 40 }"
"Expected value of type `as#Other`, but got type `Class`. Value: as#Base"
"Expected value of type `as#Other`, but got type `Listing`. Value: new Listing { \"Expected value of type `as#Other`, but got type `String`. Valu..."
Expand Down Expand Up @@ -124,7 +124,7 @@ examples {
}
["derived class"] {
new {}
"Expected value of type `as#Derived`, but got type `as#Base`. Value: new Base {}"
"Expected value of type `as#Derived`, but got type `as#Base`. Value: new as#Base {}"
}
["Mapping"] {
new {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ examples {
"new Listing { 1; 2; 3 }"
"new Mapping { [\"Pigeon\"] = 42; [\"Barn Owl\"] = 21 }"
"new Dynamic { name = \"Pigeon\"; age = 42 }"
"new Person { name = \"Pigeon\"; age = 42 }"
"new string#Person { name = \"Pigeon\"; age = 42 }"
"My name is Pigeon and I'm 42 years old."
"null"
"null"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ res1 {
street = "Hampton St."
}
}
res2 = "Type constraint `street.endsWith(\"St.\")` violated. Value: new Address { street = \"Garlic Blvd.\" }"
res2 = "Type constraint `street.endsWith(\"St.\")` violated. Value: new constraints3#Address { street = \"Garlic Blvd.\" }"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ res1 {
z = 12
}
}
res2 = "Type constraint `multiply(subtract(add(5, 4), 3), 2) == z` violated. Value: new Y { z = 13 }"
res2 = "Type constraint `multiply(subtract(add(5, 4), 3), 2) == z` violated. Value: new constraints7#Y { z = 13 }"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)

This value was converted during rendering. Previous: new ModuleClass {}. After: "anyConverterError".
This value was converted during rendering. Previous: new anyConverterError {}. After: "anyConverterError".

xxx | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
–– Pkl Error ––
Type constraint `firstOneIsSandy` violated.
Value: new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }
Value: new Listing { new constraintDetails1#Bird { name = "Bob" }; new constraintDet...

(it: Listing<Bird>) -> it[0].name == "Sandy"
│ │ │ │
│ │ │ false
│ │ "Bob"
│ new Bird { name = "Bob" }
new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }
│ new constraintDetails1#Bird { name = "Bob" }
new Listing { new constraintDetails1#Bird { name = "Bob" }; new constraintDetails1#Bird { name = ...

x | birds: Listing(firstOneIsSandy) = new {
^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
–– Pkl Error ––
Type constraint `let (myself: Listing<Bird> = this)
myself[0].name == "Sandy"` violated.
Value: new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }
Value: new Listing { new constraintDetails2#Bird { name = "Bob" }; new constraintDet...

let (myself: Listing<Bird> = this)
new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }
new Listing { new constraintDetails2#Bird { name = "Bob" }; new constraintDetails2#Bird { name = ...

myself[0].name == "Sandy"
│ │ │ │
│ │ │ false
│ │ "Bob"
│ new Bird { name = "Bob" }
new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }
│ new constraintDetails2#Bird { name = "Bob" }
new Listing { new constraintDetails2#Bird { name = "Bob" }; new constraintDetails2#Bird { name = ...

x | let (myself: Listing<Bird> = this)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
–– Pkl Error ––
Type constraint `toList().every((it: Listing<Bird>) -> it[0].name == "Bob")` violated.
Value: new Listing { new Listing { new Bird { name = "Eagle" }; new Bird { name = ? ...
Value: new Listing { new Listing { new constraintDetails3#Bird { name = "Eagle" }; n...

toList().every((it: Listing<Bird>) -> it[0].name == "Bob")
│ │
│ false
List(new Listing { new Bird { name = "Eagle" }; new Bird { name = ? } })
List(new Listing { new constraintDetails3#Bird { name = "Eagle" }; new constraintDetails3#Bird { ...

x | foo: Listing(toList().every((it: Listing<Bird>) -> it[0].name == "Bob")) = new {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
–– Pkl Error ––
Cannot iterate over value of type `forGeneratorCannotIterateOverTyped#Person`.
Value: new Person {}
Value: new forGeneratorCannotIterateOverTyped#Person {}

x | for (_ in new Person {}) { 42 }
^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
–– Pkl Error ––
Expected value of type `listingTypeCheckError9#Bar`, but got type `listingTypeCheckError9#Foo`.
Value: new Foo {}
Value: new listingTypeCheckError9#Foo {}

x | local c = b as Listing<Bar>
^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
–– Pkl Error ––
Expected value of type `mappingTypeCheckError11#Bar`, but got type `mappingTypeCheckError11#Foo`.
Value: new Foo {}
Value: new mappingTypeCheckError11#Foo {}

x | local c = b as Mapping<Int, Bar>
^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
–– Pkl Error ––
Type constraint `name?.contains("Bob") ?? false` violated.
Value: new Bird { name = "Pigeon" }
Value: new typeConstraints16#Bird { name = "Pigeon" }

name?.contains("Bob") ?? false
│ │ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Value: "Huzzah"
startsWith(bub.name)
│ │ │
false │ "Bub"
new Person { name = "Bub" }
new typeConstraints2#Person { name = "Bub" }

x | foo: String(startsWith(bub.name)) = "Huzzah"
^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
–– Pkl Error ––
Cannot iterate over value of type `spreadSyntaxCannotIterateOverTyped#Person`.
Value: new Person { name = ? }
Value: new spreadSyntaxCannotIterateOverTyped#Person { name = ? }

x | ...person
^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xx | theNumber : Int
^^^^^^^^^
at undefinedProperty3#C.theNumber (file:///$snippetsDir/input/errors/undefinedProperty3.pkl)

The above error occurred when rendering path `a.b[new D { dProperty = "dProperty" }].`bar-baz`.theNumber` of module `file:///$snippetsDir/input/errors/undefinedProperty3.pkl`.
The above error occurred when rendering path `a.b[new undefinedProperty3#D { dProperty = "dProperty" }].`bar-baz`.theNumber` of module `file:///$snippetsDir/input/errors/undefinedProperty3.pkl`.

xxx | renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ example5 {
}
}
example6 {
result = "Expected value of type `amendLambdaParametersTyped#Baz`, but got type `amendLambdaParametersTyped#Foo`. Value: new Foo {}"
result = "Expected value of type `amendLambdaParametersTyped#Baz`, but got type `amendLambdaParametersTyped#Foo`. Value: new amendLambdaParametersTyped#Foo {}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ res7 = 22
res8 = 44
res9 = 44
res10 = "Operator `|>` is not defined for operand types `Int` and `Int`. Left operand : 42 Right operand: 21"
res11 = "Operator `|>` is not defined for operand types `Int` and `pipeOperator#Person`. Left operand : 42 Right operand: new Person {}"
res11 = "Operator `|>` is not defined for operand types `Int` and `pipeOperator#Person`. Left operand : 42 Right operand: new pipeOperator#Person {}"
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
res1 = "Cannot instantiate, or amend an instance of, external class `Int`."
res2 = "Cannot instantiate, or amend an instance of, external class `List`."
res3 = "Cannot instantiate, or amend an instance of, external class `List`."
res4 = "Object of type `new Person {}` cannot have an element."
res4 = "Object of type `new wrongParent#Person {}` cannot have an element."
res5 = "Cannot instantiate abstract class `ValueRenderer`."
res6 = "Object of type `new Mapping {}` cannot have an element."
res7 = "Cannot instantiate, or amend an instance of, external class `Int`."
res8 = "Cannot instantiate, or amend an instance of, external class `List`."
res9 = "Cannot instantiate, or amend an instance of, external class `List`."
res10 = "Object of type `new Person {}` cannot have an element."
res10 = "Object of type `new wrongParent#Person {}` cannot have an element."
res11 = "Cannot instantiate abstract class `ValueRenderer`."
res12 = "Object of type `new Mapping {}` cannot have an element."
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
res1 = "Cannot instantiate, or amend an instance of, external class `Int`."
res2 = "Cannot instantiate, or amend an instance of, external class `List`."
res3 = "Cannot instantiate, or amend an instance of, external class `List`."
res4 = "Object of type `new Person {}` cannot have an entry."
res4 = "Object of type `new wrongParent#Person {}` cannot have an entry."
res5 = "Cannot instantiate abstract class `ValueRenderer`."
res6 = "Element index `0` is out of range `0`..`-1`."
res7 = "Cannot instantiate, or amend an instance of, external class `Int`."
res8 = "Cannot instantiate, or amend an instance of, external class `List`."
res9 = "Cannot instantiate, or amend an instance of, external class `List`."
res10 = "Object of type `new Person {}` cannot have an entry."
res10 = "Object of type `new wrongParent#Person {}` cannot have an entry."
res11 = "Cannot instantiate abstract class `ValueRenderer`."
res12 = "Element index `0` is out of range `0`..`-1`."
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
–– Pkl Error ––
Expected value of type `*RemoteDependency | Project(isValidLoadDependency)`, but got a different `pkl.Project`.
Value: new ModuleClass { package = ?; tests = ?; dependencies { ["badLocalProject"] ...
Value: new pkl.Project { package = ?; tests = ?; dependencies { ["badLocalProject"] ...

xxx | dependencies: Mapping<String(!contains("/")), *RemoteDependency | Project(isValidLoadDependency)>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.Project#dependencies (pkl:Project)

* Value is not of type `Project(isValidLoadDependency)` because:
Type constraint `isValidLoadDependency` violated.
Value: new ModuleClass { package = ?; tests = ?; dependencies { ["badLocalProject"...
Value: new pkl.Project { package = ?; tests = ?; dependencies { ["badLocalProject"...

(it: Project) ->
isUriLocal(projectFileUri, it.projectFileUri)
│ │ │ │
true │ │ "file:///$snippetsDir/projects/badProjectDeps4/PklProject"
│ new ModuleClass { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
│ new pkl.Project { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
"file:///$snippetsDir/projects/badProjectDeps4/PklProject"

&& it.projectFileUri.endsWith("/PklProject")
│ │ │ │
│ │ │ true
│ │ "file:///$snippetsDir/projects/badProjectDeps4/PklProject"
│ new ModuleClass { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
│ new pkl.Project { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
true

&& it != module
│ │ │
│ │ false
│ new ModuleClass { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
│ new pkl.Project { package = ?; tests = ?; dependencies { ["badLocalProject"] = ? }; evaluatorSett...
false

&& it.package != null
Expand Down
Loading