Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1368·pkl

Amending an undefined property with a union type with no default member should produce a more specific error

Author: joshqouCreated Dec 13, 2025Updated Aug 28, 2026

When a field is typed as Listing or String, Pkl will fail to intuit the type of the value if it inherits from Dynamic. Int will also be intuited correctly, whereas Mapping is also not intuited.

Example:

pkl
class ExampleTyped {
    aa: Listing<String> | String
    bb: String
}

typed: ExampleTyped = new {
    aa { "hello" } // aa = new Listing { "hello" } works fine
    bb = "hello"
}

Pkl Error:

– Pkl Error ––
Tried to read property `aa` but its value is undefined.

21 | aa: Listing<String> | String
     ^^
at example.aa (file:///path/to/example.pkl, line 21)

The above error occurred when rendering path `typed.aa` of module `file:///path/to/example.pkl`.

128 | renderer.renderDocument(value)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (https://github.com/apple/pkl/blob/0.30.1/stdlib/base.pkl#L128)

132 | if (renderer is BytesRenderer) renderer.renderDocument(value) else text.encodeToBytes("UTF-8")
                                                                         ^^^^
at pkl.base#Module.output.bytes (https://github.com/apple/pkl/blob/0.30.1/stdlib/base.pkl#L132)

Version: Pkl 0.30.1 (Linux 6.11.0-1018-azure, native)

Source: apple/pkl

View original on GitHubView discussion on GitHub