437 Commits
Author SHA1 Message Date
Jen Basch 2d7a368b48 Remove protobuf stdlib module (#1976) 2026-11-10 17:03:09 +00:00
Jen Basch 155fc5a867 Turn module type usage warnings into errors (#1977) 2026-11-10 09:59:40 -07:00
Dan Chao 095f064148 Start next dev iteration 2026-11-05 12:52:24 -08:00
Dan Chao 1c785a75af Prepare 0.33.0 release 2026-11-05 12:52:24 -08:00
Islon Scherer fc5d658aa3 Add an s-exp renderer to pkl:syntax (#1955) 2026-11-05 17:10:33 +00:00
Daniel Chao 85b4a4669a Rename render to renderValue (#1964)
Motivation: preserve a possible API change to have `FormattingRenderer`
extend `ValueRenderer`.
2026-11-05 08:39:33 -08:00
Daniel Chao 1f5c62ecef Refine requirements around const and this type (#1962)
This introduces a rule that const properties cannot use the `this` type if that referenced type exceeds the scope.

This code is an error:

```pkl
const foo: this
```

This is not:

```pkl
const foo = new {
  local myself: this
}
```

Additionally, this fixes:

* const depth logic to account for eager scopes
* behavior of `this` type inside custom this scopes
2026-11-04 11:30:50 -08:00
Daniel Chao ffd8a5d484 Remove treatment of %5c as a slash on Windows (#1954)
We reject any filepath that contains a `\` character;
all Pkl code must use `/` as the path separator.

So, we don't need to normalize `%5c` as a path sep on Windows.
2026-11-03 13:21:36 +00:00
Daniel Chao a9b7fe3a33 Switch type argument syntax (#1940)
This changes type argument syntax to "standard" style, and away from turbofish.

The motivation here is that turbofish-style type arguments are hard to read, and developers who are not already deeply knowledgeable about Pkl might struggle to understand such code.
In most languages, the grammar for "method call with type args" don't introduce any additional symbols between the identifier and the type argument list (e.g. C++, TypeScript, C#, Scala, Go).
2026-11-03 05:09:40 -08:00
Daniel Chao 6ad50eb589 Make stack overflows more robust (#1953)
Fixes an issue where we fail to initialize class
`VmStackOverflowException` when re-throwing a StackOverflowEexception.
2026-11-03 05:07:24 -08:00
Daniel Chao 89cb6c98a1 Improve normalization of URIs (#1937)
This adds changes such that URIs like `file:///path/to/%2E%2E/bar.txt`
are considered path traversal sequences.

These URIs are treated as dot segments, and normalized prior to calling
into security checks.

For package URIs, the same treatment is applied to the
URI fragment.

jar-file URIs are special-cased and normalized as well.

Additionally, `%2f` is treated as `/` for file, jar-file and asset path segments.
However, these are left alone for other URIs (RFC-3986 treats `%2e` as identical to `.`, but `%2f` as distinct from `/`)..
2026-10-30 21:04:27 -07:00
Daniel Chao 5cb5d41a44 Fix VmDynamicCursor (#1948)
This fixes an issue where it fails to iterate over this entry:
`new Dynamic { [-1] = 2 }`
2026-10-30 21:45:36 +00:00
Daniel Chao b1b36b09ac Fix computation of hash codes for Listing, Duration, DataSize (#1922)
These are currently breaking the principle of: if two objects are
`equals`, then they have the same hash code.
2026-10-30 10:31:06 -07:00
Daniel Chao 0b582b50b4 Fix some GraalVM PE issues (#1944)
* VmObject.getRootFirstObject() is a recursive call, which sometimes
  fails with "too deep inlining"
* Incorrect loop condition profile usage in some places
* Need to mark `checkedReturnTypeNode` final so that GraalVM knows
  that it is PE constant
2026-10-30 10:27:18 -07:00
Daniel Chao 99c2d84c43 Fix enforcement of const member access inside methods (#1945) 2026-10-30 16:57:49 +00:00
Aashish Mahato e0d727be60 Fix toString/.value saturation for Duration and DataSize values too large for a long (#1935) 2026-10-29 08:23:50 -07:00
Islon Scherer 434f699887 Add limits to parser recursion (#1918) 2026-10-27 16:57:36 +01:00
Jen Basch 21d278eba5 Add user generic methods (#1849) 2026-10-27 07:17:08 -07:00
Islon Scherer 939e844c03 Add pkl:syntax stdlib module (#1821) 2026-10-23 15:51:22 +02:00
Jen Basch 0cb9843af7 Fix module type check defined in parent member bodies (#1936) 2026-10-22 12:00:49 -07:00
Jen Basch 05d8e88592 Fix checking of subscript key types references to Map/Mapping (#1933) 2026-10-22 17:01:46 +00:00
Aashish Mahato dd83b9ab4f Fix hashCode/equals inconsistency for negative zero in Duration and DataSize (#1932) 2026-10-22 09:07:34 -07:00
Daniel Chao a06684b2c0 Improve error message thrown for "cannot instantiate" (#1916)
If the parent comes from an implicit node (e.g. read super entry node),
Pkl will currently bury its source section when rendering the error
message.
2026-10-20 08:42:18 -07:00
Goutam Adwant ce977f1ffe Fix parameterized type checks in alias constraints (#1906)
Fixes an issue where a constraint inside a typealias that writes to frame slots is unable to resolve type arguments.
2026-10-19 23:29:30 +00:00
Daniel Chao 08f0c3781b Improve error messages when typealiases fail to check (#1914)
This adds the typealias' usage site to the stack frame.
2026-10-19 12:34:04 -07:00
Daniel Chao 97c73e7c28 Fix qualified type resolution (#1915)
Fixes an issue where `GetModuleOwnerNode` resolves to levelsUp == 0,
but its enclosing owner is a parse-time invisible scope.
2026-10-19 12:23:38 -07:00
Daniel Chao ef5e34c210 Fix failing Windows build (#1912)
This test is failing, but is also moot now because file URIs now
forbid authority components.
2026-10-16 19:18:11 +00:00
Aagam Shah e18d962033 Force the returned value in test.catch() and test.catchOrNull() (#1910) 2026-10-16 12:02:33 -07:00
9f79fe47da Replace VmObjectLike.iterateMemberValues() with VmObjectCursor (#1879)
Motivation:
- VmObjectLike.iterateMemberValues() is an internal iterator whose loop body is a Java lambda.
  It suffers from the following limitations:
  - `continue` and `break` cannot be used.
  - `return` becomes an (awkward) replacement for `continue` and `break`.
    It cannot be used to return from the enclosing method.
  - Mutating variables requires hoisting them (MutableBoolean, etc.).
  - Node.execute() calls are very slow because they are behind a Truffle boundary.
  - Callers of iterateMemberValues() do not specify what and how they want to iterate.
    This obscures the iteration code and makes it difficult (often impossible) to optimize.

Changes:
- Add interface VmObjectCursor, an external iterator that iterates over VmObject members.
  Its design is inspired by org.graalvm.collections.MapCursor.
- Add VmObjectCursor implementations specialized for different members, VmObject subclasses, and cursor options.
- Replace VmObjectLike.iterateMemberValues() with the following methods that return VmObjectCursor:
  - properties()
  - properties(CursorOption)
  - elements()
  - elements(CursorOption)
  - entries()
  - entries(CursorOption)
  - members
  - members(CursorOption)
- Replace all usages of iterateMemberValues() with one of the above methods.
  Before: object.iterateMembersValues((key, member, value) -> { if (member.isProp()) {...} });
  After : for (var cursor = object.properties(); cursor.advance(); ) {...}

Result:
- Iteration code is much simpler and clearer.
- Iteration code that calls Node.execute() is much faster because it is no longer behind a Truffle boundary.
- Other iteration code is potentially faster and can be better optimized in the future.

Co-authored-by: translatenix <119817707+translatenix@users.noreply.github.com>
Co-authored-by: Jen Basch <jbasch94@gmail.com>
2026-10-16 17:47:18 +00:00
Carpe-WangandJen Basch eff9a9e164 [fix] Add support for handling remote file URIs. (#629)
Co-authored-by: Jen Basch <jbasch@apple.com>
2026-10-15 14:05:46 -07:00
Maycon Campos 8399f11186 Document public module APIs (#1813) 2026-10-15 13:27:05 -07:00
f96fba00e1 Add a CPU profiler (#1823)
This introduces a way to run CPU profiling.

The profiler produces output in pprof format.

CLI users can enable CPU profiling via command line flags.
Profiling is otherwise not offered as an API.

Co-authored-by: Jen Basch <jbasch94@gmail.com>
Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-10-15 15:57:55 +00:00
Alexandre Kohler f4ad0da658 Fix lookaround regexes in String.lastIndexOf and replaceLast (#1908) 2026-10-13 11:32:12 -07:00
Daniel Chao f973fd6717 Change how VmValueRenderer renders Typed values (#1412)
This changes it to render the qualified name instead of the simple name.

* Module classes render the module name
* Classes within module render the module name and the class name joined by `#`
* Rendering of members of `pkl:base` does not change

For example:

* `new k8s.core.v1.Service {}` instead of `new ModuleClass {}`.
* `new k8s.core.v1.Service#ServiceSpec {}` instead of `new ServiceSpec {}`
* `new pkl.Project {}` instead of `new ModuleClass {}`

This affects the following:

* `toString()`
* `trace()`
* Error messages
* REPL
2026-10-08 13:32:26 -07:00
Vladimir Matveev 66fb5c133b Module cache directory propagation (#1900)
Currently the module cache directory in CLI commands (and thus in Gradle tasks, since they use CLI commands under the hood) is only used for the "primary" task. For example, for an eval command, the module cache directory will be used for the evaluation of the target module.

However, most commands also work with projects, and for projects the `PklProject` file must be evaluated. This is done via `Project.loadFromPath`, which internally builds an evaluator with the default module cache path. Therefore, all evaluations of project manifests always use default cache path instead of whatever is configured through the CLI option/Gradle task property. This, in turn, may result in unexpected behavior: in general, the user would expect that if they specify the cache directory, it will be used for all evaluations (e.g. when they pre-populate the cache and expect evaluations to work offline).

The same is true for settings evaluation, although for settings it is significantly less important since settings scripts can't have remote dependencies.

This PR propagates cache path into the project evaluator (as well as the settings evaluator, for consistency). This will result in the user-specified cache directory being used for `PklProject` evaluations as well.
2026-10-07 13:58:40 -07:00
Islon Scherer 862c61f2e2 Add net stdlib module with URL support (#1834) 2026-10-06 15:23:32 +02:00
Daniel Chao dbcecd9677 Fix decoding of pkl-binary into Java Pattern (#1895)
Patterns that originate from the language runtime will add
`Pattern.UNICODE_CHARACTER_CLASS | Pattern.UNICODE_CASE` as implicit
regex flags, so we need to do the same on the binary decoding side.
2026-10-05 09:09:30 -07:00
Daniel Chao ba25f4820c Perf improvements for String.endWith(Regex) (#1884)
* Compute a derived regex expression with `\z` anchor
* Ensure derived regex can't be messed up with comments (in extended mode) or quote start

Follow up to #1880
2026-10-05 09:09:03 -07:00
Jen Basch adaafc4045 Fix external reader process leak in pkl-server (#1885) 2026-10-02 14:16:25 -07:00
Daniel Chao 82fe176c69 Improve cases where type nodes can turn into TypeNode.UnionOfStringLiterals (#1875)
This adds logic to UnresolvedTypeNode to create a `UnionOfStringLiterals`
type node if a member is a typealias who is a string or a string literal union.

Also, this fixes an issue where marking a duplicate string literal with the
default marker throws an index out of bounds exception.
2026-10-02 09:16:25 -07:00
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
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