381 Commits
Author SHA1 Message Date
Dylan Pulver f3efcbfc9b Escape characters that YAML cannot carry literally (#1846)
YamlEmitter only routed a string into YamlEscaper when it held a
character below 0x20, so 0x7F, the C1 block, U+2028 and U+2029 went out
as plain scalars. They are not `c-printable` (YAML 1.2 spec 5.1), and
NEL, LS and PS are line breaks in YAML 1.1, so the rendered document is
either rejected or silently split by a reader.

The escapes added in #1165 for 0x85, 0xA0, U+2028, and U+2029 could only
fire when some other character happened to open that gate. Share one
predicate between the two sites that decide, and give 0x7F-0x9F the
8-bit escape they lack.
2026-09-04 13:46:09 -07:00
Jen Basch f284a0560a Error when inferring a self type in a method argument (#1847) 2026-09-03 23:03:34 +00:00
Jen Basch 249e563291 Optimize new inference in method args (#1845) 2026-09-03 13:16:17 -07:00
Jen Basch 7f5ae2a712 Add inference for implicitly typed new in method arguments (#1768) 2026-09-02 23:55:24 +00:00
Daniel Chao 92b26aca17 Optimize annotations without object bodies (#1843)
This skips some unnecessary steps when evaluating annotations that
have no attached object bodies by returning an EmptyObjectLiteralNode
instead of a PropertiesLiteralNode
2026-09-02 13:04:26 -07:00
Daniel Chao 0035199176 Improve partial-evaluation when amending null parents (#1836)
GraalVM's partial evaulator can't handle recursive calls into the same
node.

The current implementation around evaluating `VmNull` as a parent causes
the partial evaluator to bail out, leaving Pkl stuck in interpreter
mode.

This rewrites the various object literals to add individual
specializations for each type of default value we can see from a VmNull
parent.

Also:
* Fix `isTypeObjectClass` impl
* Fix bug when amending with generator object literal node with object params
2026-09-02 18:18:55 +00:00
Daniel Chao 2c2f50113d Make enclosing frame lookup more PE friendly (#1842)
The truffle compiler currently _always_ bails out of compilation for
`VmUtils.getFrame()` calls, because it determines that some branch
of this code can possibly return a materialized frame.

This adjusts the code so that the hot path (levelsUp == 0)
does not touch `VmUtils.getFrame()`, and avoids unnecessarily
materializing the frame.
2026-09-02 10:01:25 -07:00
Daniel Chao 9f28c1cb11 Make listing/mapping typecasts more PE-friendly (#1837)
This rewrites the listing/mapping typecast nodes to be more friendly
to partial-evaluation.

This is because the compiler bails out of deeply recursive calls.
2026-09-02 10:00:59 -07:00
Jen Basch 2b697015c7 Add this as a self type (#1708) 2026-09-02 09:04:15 -07:00
Daniel Chao 1208fa9438 Improve reading of const members (#1835)
The previous implementation can cause the JIT compiler to permanently
bail out when reading const memebrs.
2026-08-28 09:18:56 -07:00
Jen Basch 1cfdd3d30d Fix native build (#1832) 2026-08-26 22:45:18 +00:00
Jen Basch cb01d6275b Correctly type check Class<T> (#1698) 2026-08-26 05:29:34 +00:00
Sergio Salvi a90eb74c2d Fix reflect crash on modules using glob imports (#1816)
This excludes glob imports when creating a module's mirror
2026-08-25 12:04:45 -07:00
Jen Basch ae9160df51 Enforce max collection sizes when decoding pkl-binary (#1831) 2026-08-25 08:28:28 -07:00
Daniel ChaoandFlorin Ungur 6551a59f9e Use XDG base directories and Known Folders on Windows (#1809)
This changes logic that previously read/wrote from `~/.pkl` to use
XDG base directories (all OSes), and Known Folders locations on Windows.

For example, Pkl will look for `settings.pkl` in:

1. `$XDG_CONFIG_HOME/pkl/settings.pkl`
2. `%APPDATA/pkl/settings.pkl`
3. `~/.pkl/settings.pkl`
4. Path pkl/settings/pkl within `$XDG_CONFIG_DIRS`
5. `/etc/xdg/pkl/settings.pkl`

---------

Co-authored-by: Florin Ungur <florin@florinungur.com>
2026-08-20 21:50:24 +00:00
Daniel ChaoandIslon Scherer 4dd37219c0 Fix name resolution of types in constraints (#1826)
This fixes an issue where type names are resolved incorrectly
in typealias constraints.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-08-19 11:10:32 -07:00
Jen Basch ac43bdbb17 Add hex/binary/octal support to String.toInt() (#1808) 2026-08-18 09:44:02 -04:00
Jen BaschandDan Chao 762db144ce Enforce that abstract methods are implemented (#1785)
This adds a check that abstract members must be implemented.
If any members lack an implementation, an error is thrown describing
the missing members.

Co-authored-by: Dan Chao <dan.chao@apple.com>
2026-08-17 21:52:54 +00:00
Jen Basch 5333d55269 Skip loading known-bad certs (#1806) 2026-07-30 22:54:08 +00:00
Daniel Chao a55a3d7c33 Improve evaluation of typealiases (#1796)
This simplifies the resolution of names in typealias constraints.
This removes the existing logic around swapping out the frame's
owner/receiver, and instead favors resolving the variable at parse time.

* During variable resolution, create read variable nodes that read off of
  a receiver node
* Introduce `GetTypeAliasModuleNode` that provides the typealias's
  enclosing module
* Inject the enclosing module during typealias instantiation
2026-07-30 17:22:45 +00:00
Jen Basch 2ca2aaf9ec Add pkl project package --install to local cache (#1795) 2026-07-30 07:26:21 +00:00
Jen Basch 50a09f59dc Remove abstract properties (#1781) 2026-07-29 15:05:19 -07:00
Daniel Chao be03023499 Fix snippet test mismatch between hotspot and native test (#1797) 2026-07-28 18:18:36 +00:00
Islon Scherer 1a3dc52a96 Fix bug in force (#1790) 2026-07-28 09:19:15 +02:00
67df676359 Introduce C library for Pkl (#1238)
This uses native-image to generate a C library for Pkl.
This generated library from native-image is wrapped with our own library,
in `pkl.h`.

This produces a static and a dynamic library for each os/arch variant
that Pkl currently supports.

Co-authored-by: Kushal Pisavadia <kushal.p@apple.com>
Co-authored-by: Jen Basch <jbasch94@gmail.com>
Co-authored-by: Islon Scherer <i_desouzascherer@apple.com>
2026-07-25 04:15:26 +00:00
David TeslerandDan Chao 175e2b6273 Fix negative caret width rendering multi-line expression errors (#1793)
The expression preamble length was subtracted from endColumn even
when endColumn came from the already-stripped sourceLine.length(),
so multi-line frames got a negative caret width and String.repeat
threw. Apply the offset only to the frame-derived columns.

---------

Co-authored-by: Dan Chao <dan.chao@apple.com>
2026-07-24 20:57:05 +00:00
Daniel Chao 2242cc9c82 Fix variable resolution of object body params (#1788)
Fixes a regression introduced in Pkl 0.32.
2026-07-22 13:04:36 -07:00
Daniel Chao 3b5e9df0da Migrate Gradle delegated properties (#1782)
There were some more that we missed last time around
2026-07-16 15:41:28 -07:00
Kushal Pisavadia 50cfc0bcde Close intermediate redirect response bodies before following (#1749)
When following redirects, `RequestRewritingClient` discarded each 3xx
response without closing its body, leaking the underlying connection.

Close the body as soon as we know the status is a redirect and won't
be returned, so the too-many-redirects, missing-`Location`,
invalid-URI and downgrade error paths all release the connection too.

This prevents leaking one `BodyHandlers.ofInputStream()` connection
per hop. Now the code closes the body before following the redirect.
2026-07-16 21:11:53 +00:00
Jen BaschandVinayak 3d03a47933 Revert "Revert "Reject abstract members in non-abstract classes" (#1688)" (#1780)
This reverts commit 1bf00b84ea.

Co-authored-by: Vinayak <vinayak@vama.app>
2026-07-16 11:34:20 -07:00
Jen Basch 71948d69c4 Upgrade to GraalVM 25.1.3, drop macOS Intel builds (#1769) 2026-07-13 15:52:02 -07:00
Daniel Chao 60b0d86b5f Fix eval -x of local members (#1760)
This fixes a regression where local members cannot be seen by the
expression evaluator.

Because variable are now parse-time resolved, this builds a truffle node
by first constructing a synthetic module of all defined local members,
and calls AstBuilder on this synthetic module first.
2026-07-11 00:03:15 +00:00
Daniel Chao 7a7f3abc50 Migrate Gradle deprecations (#1745) 2026-07-08 12:05:19 -07:00
Dan Chao 997cfc9ae2 Start next dev iteration 2026-07-08 10:29:48 -07:00
Dan Chao 9916c23cfc Prepare 0.32.0 release 2026-07-08 10:29:48 -07:00
Daniel Chao 010d971af0 Add tests for empty IntSeq iteration (#1739) 2026-07-08 06:37:56 -07:00
Daniel Chao bd83e29641 Normalize asset paths in local dependencies (#1737)
This changes local asset path resolution so that `..` segments at the
dependency root just resolves to the dependency root.

This makes import resolution work the same between local and remote dependencies.
2026-07-08 05:43:36 -07:00
Daniel Chao 2ec62c99a7 Enforce stricter rules on reference access (#1718)
This changes the following:

1. If given a union type, the member must exist on each member of that type
2. If accessing a member off `Reference<D, Null>`, give a `Reference<D, Null>`

Also:
* Improve error messages thrown during member access.
* Add test around accessing members off of a function type
2026-07-06 19:24:14 -07:00
Daniel Chao eaf73af247 Improve thread safety for pkl:base (#1719)
Stdlib modules are singletons that are shared across multiple evaluators.
This improves thread safety by evaluating its `output.bytes` during
initialization, which initializes truffle nodes (e.g. TypeTestNode),
and also initializes the member cache of the module output of `pkl:base`
2026-07-06 11:19:29 -07:00
Daniel Chao 2ec83198f5 Fix replacements of types nested within nested constraints (#1731)
Also, adjust tests
2026-07-06 08:58:56 -07:00
Jen Basch 6a4d3acf21 Fix incorrect isNoopTypeCheck() calls (#1717)
`isNoopTypeCheck()` is not reliable when inside a TypeNode's constructor. This defers these calls to node execution time.
2026-07-02 14:24:55 -07:00
adityabagchi24andDaniel Chao 1c1a39e37f Fix type argument lost in constraint expressions within generic typealiases (#1709)
Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2026-07-01 10:10:03 -07:00
Jen Basch bfa6a989be Generalize TypeNode validation (#1715) 2026-06-30 08:50:35 -07:00
Jen Basch 70fc1d4ba3 Correctly handle type aliases with a type variable as the root (#1714) 2026-06-30 06:49:21 +00:00
Daniel Chao 139d1ae8ec Fix many editor diagnostics (#1707)
This addresses many IDE warnings resulting from the switch to JSpecify.

Also, this changes the behavior of exporting VmObject; there's no place
in our code that does not force a VmObject prior to export, so
the existing logic around handling nullable values has been removed.
2026-06-29 16:22:19 +00:00
Daniel Chao 742a8e88da Fix for-generator variable resolution in nested eager scope (#1706)
Fixes an issue around resolving for-generator variables in some cases
2026-06-29 09:07:51 -07:00
Islon Scherer 6239981869 Improve error message for aliased references (#1695) 2026-06-29 18:06:34 +02:00
Islon Scherer d42e199da3 Fix wrong error key in ReflectNodes (#1694) 2026-06-25 09:21:03 +02:00
Daniel Chao f61a5cf541 Check if receiver is a module object in relativePathTo (#1650)
Closes #1649
2026-06-24 11:48:57 +02:00
Islon Scherer dd6939ab3f Add equals and hashcode to PType (#1691) 2026-06-24 11:31:11 +02:00