Produce more helpful output when module output is overwritten (#716)

Fix a bug where overwriting `output` causes a PklBugException.

This now produces a more helpful message pointing to the actual problem.

Co-authored-by: translatenix <119817707+translatenix@users.noreply.github.com>
This commit is contained in:
Josh B
2024-10-24 09:41:59 -07:00
committed by GitHub
parent cbbcca0d84
commit 4b6bc7bb7c
9 changed files with 64 additions and 7 deletions

View File

@@ -0,0 +1 @@
output: String = "abc"

View File

@@ -0,0 +1,3 @@
class Test {}
output: Test = new {}

View File

@@ -0,0 +1 @@
output = null

View File

@@ -0,0 +1,6 @@
Pkl Error
Expected `output` of module `file:///$snippetsDir/input/errors/invalidOutput1.pkl` to be of type `ModuleOutput`, but got type `String`.
x | output: String = "abc"
^^^^^
at output (file:///$snippetsDir/input/errors/invalidOutput1.pkl)

View File

@@ -0,0 +1,6 @@
Pkl Error
Expected `output` of module `file:///$snippetsDir/input/errors/invalidOutput2.pkl` to be of type `ModuleOutput`, but got type `invalidOutput2#Test`.
x | output: Test = new {}
^^^^^^
at output (file:///$snippetsDir/input/errors/invalidOutput2.pkl)

View File

@@ -0,0 +1,10 @@
Pkl Error
Expected value of type `ModuleOutput`, but got `null`.
xx | hidden output: ModuleOutput = new {
^^^^^^^^^^^^
at pkl.base#Module.output (pkl:base)
x | output = null
^^^^
at invalidOutput3#output (file:///$snippetsDir/input/errors/invalidOutput3.pkl)