Commit Graph
913 Commits
Author SHA1 Message Date
Daniel Chao b8c7a42318 Make typechecking more PE friendly (#1871)
This makes various improvements to help truffle do partial
evaluation of code related to typechecking.

* Split `UnionTypeNode` into `UnionTypeNodeExploded` and
 `UnionTypeNodeLooped` to avoid gigantic graphs. This especially helps
  in the case of typealiases, because they are inlined into their usage
  sites.

* Move constraint-failure exception construction in
  `TypeConstraintNode` behind `@TruffleBoundary` helper methods
  instead of `transferToInterpreterAndInvalidate`, since building the
  exception is a rare, off-hot-path operation.

* Move `ClassNode`'s one-time class-initialization logic behind a
  `@TruffleBoundary` method (`initClass`), store `VmLanguage` as a
  field instead of recomputing it via `VmLanguage.get(this)`, and use
  `transferToInterpreterAndInvalidate` since class init never needs to
  re-run on the compiled path.

* Pass `VmLanguage` explicitly into `TypeTestNode` and `ClassNode`
  (via `AstBuilder`) rather than resolving it with
  `VmLanguage.get(this)` on a hot path.

* Fix various issues where the partial evaluator determines that a frame
  should have been materialized but was not.

* Pre-initialize call targets in `ObjectMember.setMemberNode()` and
  `FunctionLiteralNode` so the first invocation doesn't trigger a
  compilation invalidation.

* Fix truffle node tree issues (don't mark `@RootNode` as child,
  deepCopy instead of passing an already adopted node).

* Remove unnecessary interpreter transfers when throwing type mismatch exceptions
2026-09-30 07:16:54 -07:00
Alexandre Kohler 8331570aaf Fix String.endsWith for overlapping regex matches (#1880) 2026-09-29 21:52:12 -07:00
Jen Basch 1271da2741 Fixes to commands where (sub)commands never extend pkl:Command (#1882) 2026-09-29 23:19:28 +00:00
apple-ospo[bot] e83d8fa14b Replace repo-level CODE_OF_CONDUCT file with the inherited org-wide Code of Conduct in .github repo. (#1878)
Co-authored-by: apple-ospo[bot] <326325757+apple-ospo[bot]@users.noreply.github.com>
2026-09-25 10:51:20 -07:00
Daniel Chao d1e043be4e Make join call overriden toString() (#1872)
This changes the `join` method in `List`/`Set`/`Listing` to
call the overridden `toString()` method.

This is a breaking change, but is considered a bugfix.
2026-09-25 09:24:16 -07:00
Daniel Chao 43e132a383 Fix "unchecked or unsafe operations" warning in javac (#1874)
Fix this printed warning during java compilation:

"Note: Some input files use unchecked or unsafe operations. Recompile with -Xlint:unchecked for details"

* Add `-Xlint:unchecked` as a javac flag
* Fix the various warnings
2026-09-24 09:28:49 -07:00
Daniel Chao 119b1571bb Switch ad-hoc vmobject building to use VmObjectBuilder (#1873) 2026-09-24 07:32:30 -07:00
Daniel Chao d5a7dc021e Switch inferred new {} expressions in method args to using frame slots (#1857)
This changes the logic for inferring `new {}` expressions in method
arguments to using regular frame slots, instead of auxiliary slots.

Overall, this is a performance improvement: no looking up auxiliary slot
numbers, which makes this code much more PE friendly.

* At parse time, get or create a frame slot that holds the method
* Introduce `ArgInfo` record (preserve primitive int) over using `Pair`
* Remove unneeded `isImplicitNewExpr` method; this is not needed because
  we can just keep track of the method slot on the frame descriptor
  builder.
2026-09-22 12:12:57 -07:00
Jen Basch 7ed88e250b Add VmType intermediate representation for types (#1838) 2026-09-22 08:26:03 -07:00
Daniel Chao cbffd6c114 Improve error message when amending a property with no value set (#1867)
Improve error message when amending a property with no value set

This decorates error messages with the amendment node.
2026-09-21 06:54:22 -07:00
Daniel Chao e0b3b87e19 Fix native image build (#1865)
PE code can't call `Object.equals`
2026-09-17 21:57:35 -07:00
Daniel Chao cec08c651e Optimize super property and super subscript nodes (#1853)
This adds cacheing to ReadSuper* nodes so that the same
node being executed can possibly re-use a previously cached value.
2026-09-17 20:46:03 -07:00
Jen Basch 397183a620 Mark overridable external properties as const (#1864) 2026-09-17 12:52:53 -07:00
Jen Basch c71b107e32 Add inference for let bindings (#1824) 2026-09-15 05:20:42 +00:00
Daniel Chao d0de24b85b Avoid using Object.toString() for in-language API (#1850)
This changes code so that the in-language `toString()` doesn't use
Java's `Object.toString()`.
Additionally, the existing `toString()` implementation is switched over
to using `VmValueRenderer`, which does not force (leaves `?` in place of
unforced values).

This helps improve ergonomics when working on the language (can enable
automatically calling `toString()` on debug values).

Additionally, external tools might call toString(); for example,
Truffle's compiler sometimes will stringify node fields (e.g.
when -Dengine.CompilationFailureAction=Throw) is set.
2026-09-11 23:08:26 +00:00
Daniel Chao e3881f6149 Fix invalid prefix when generating spring boot config (#1862)
Fix invalid prefix when generating spring boot config

In Spring Boot, the prefix passed to `@ConfigurationProperties` must
be in "canonical form".

The presence of this annotation allows spring boot to directly inject
properties into a class, but is not actually needed.

The correct behavior here is to omit this annotation if the property
name does not match Spring Boot's canonical form.
2026-09-11 15:49:04 -07:00
Daniel Chao 9b52a4fd82 Fix CI on Windows (#1861)
Fix bad assertion: `IoUtils.getSystemModuleCacheDir()` uses the actual
OS env, but the test hard-codes `isWindows` to false.
2026-09-11 11:09:37 -07:00
Daniel Chao 8fba228790 Fix failing test on Windows (#1858) 2026-09-10 21:31:19 -07:00
Jen Basch 574ad844f3 Use ChoiceFormat for better plurals in error messages (#1848) 2026-09-10 22:03:05 +00:00
Daniel Chao 90245589b6 Improve documentation on netRcHeaders method (#1854) 2026-09-09 15:30:08 -07:00
Yarden Bar c95b3d11f4 Add netrc helpers in EvaluatorSettings.pkl (#1817)
This adds the `netRcHeaders` helper method that parses netrc file contents, and returns a mapping suitable to be used as Http headers.
2026-09-09 14:25:06 -07:00
Daniel Chao 713adac824 Make generator nodes more PE friendly (#1844)
* In GeneratorWhenNode, need to move individual iterations into their
  own methods so that the @ExplodeLoop sees a constant number of
  iterations whenever that method is called.
* In the other nodes, the lambda passed to
  `forceAndIterateMemberValues` needs to capture the materialized frame,
  not the virtual frame.
2026-09-08 15:11:10 -07:00
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
Daniel Chao adee565a8c Mark protobuf module as deprecated (#1778)
This moves the protobuf module from experimental to deprecated

Rationale:

* This is very seldom used, if used at all
* Not fully fleshed out (this really should be paired with a protoc-gen-pkl, which doesn't exist)
* There is a ProtoJSON wire format that we can already render to
2026-09-02 09:26:51 -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
Jen Basch 79af6b1676 Sanitize block comment endings in generated Kotlin doc comments (#1830) 2026-08-25 08:27:30 -07:00
Sergio Salvi 7404f7d160 Fix block comment at EOF without trailing newline (#1828) 2026-08-21 15:46:37 -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
Daniel Chao 99c9f53063 Remove community.adoc page (#1820)
This is being moved to pkl-lang.org
(see https://github.com/apple/pkl-lang.org/pull/172).
2026-08-10 11:23:24 -07:00
Daniel ChaoandIslon Scherer c5896d76d0 Split libpkl libraries between shared and static libs (#1812)
This adds a `libpkl-static.pc` so pkg-config users can link either
statically or dynamically via `pkg-config --libs libpkl`, or
`pkg-config --libs libpkl-static`.

Additionally, this fixes an issue where the replace tokens wasn't
doing anything, leaving the `@version@` token intact in the archive.

Additionally, this adds an `-install_name` when building the dylib for macOS.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-08-07 15:47:16 +00:00
Jen Basch b3698683ab Upgrade to GraalVM 25.2.4 (#1804) 2026-08-03 09:24:53 -07:00
Daniel Chao 417c08ae11 Fix various issues in libpkl (#1805)
* Fix possible SIGSEGV from host process.
   - Require that the same `pkl_exec_t` be used in the same OS thread; returning meaningful error if this fails
* Remove `System.exitProcess(1)` logic in NativeTransport; this would kill the host process too and isn't an appropriate action for a received ProtocolException
* Allow multiple calls to pkl_init without pkl_close; this limitation doesn't really make any sense
* Prefer calling methods defined in graal_isolate.h, instead of creating the same method via CEntryPoint
* Add a CMakeLists.txt so that CLion can follow the code and provide proper diagnostics
* Improve doc comments; describe params as either in or out
2026-07-31 16:23:37 +00:00
Jen Basch 5333d55269 Skip loading known-bad certs (#1806) 2026-07-30 22:54:08 +00:00
043f0e129b Add documentation for libpkl (#1801)
This adds a new Antora module for libpkl, and updates the language
bindings documentation.

Co-authored-by: Jen Basch <jbasch94@gmail.com>
Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-07-30 17:24:27 +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