Commit Graph

279 Commits

Author SHA1 Message Date
Daniel Chao 07c68239b9 Remove lockfiles, manage Gradle dependencies with Dependabot (#1535)
Dependabot currently does not update lockfiles in multi-module projects
(see https://github.com/dependabot/dependabot-core/issues/14633)

To work around this issue, we will simply remove our lockfiles, and
change our version catalog to use fully specified versions.
The removal of lockfiles introduces two issues:

1. It is less visible what our dependency graph is
2. Our builds are potentially non-reproducible

To work around this, two mitigations are in place:

1. Enable `failOnDynamicVersions()`, which causes Gradle to fail the
build if any dependencies declare a version range
2. Enable GitHub dependency submission, which provides insight into the
project SBOM
2026-04-20 09:29:33 -07:00
Jen Basch eeb0970dc4 Fix bug where reusing a pklbinary#Renderer could result in incorrect output (#1525) 2026-04-15 23:12:36 -07:00
odenix 4faf35a66a Gradle: Replace legacy buildSrc mechanism with included build (#1524)
Motivation:
buildSrc is a special-case legacy mechanism.
Gradle recommends using an included build named build-logic instead:

https://docs.gradle.org/current/userguide/best_practices_structuring_builds.html#favor_composite_builds

Changes:
- Rename buildSrc/ to build-logic/
  - triggers reformatting
- Replace occurrences of "buildSrc" with "build-logic"
- Include the build-logic build in the main build (via
settings.gradle.kts)
- Apply convention plugins via plugin IDs instead of type-safe accessors
  - small tradeoff compared to buildSrc

Result:
- Faster and more isolated builds
- Build logic behaves like a normal build, making it easier to evolve
and reason about

---------

Co-authored-by: Daniel Chao <dan.chao@apple.com>
2026-04-15 21:37:10 -07:00
odenix 04a9cc90d2 Improve build logic for Kotlin (#1520)
- Enforce Kotlin version via resolution rule (replaces BOM)
  - fail if kotlin-stdlib/kotlin-reflect exceed target version
- Replace kotlin-stdlib-jdk8 with kotlin-stdlib (jdk7/8 are now shims)
- Port pkl-core annotation processor to Java (with Codex)
- removes kotlin-stdlib from its compile classpath for better dependency
hygiene (Java module)
- Downgrade clikt for Kotlin 2.2 compatibility
- Upgrade kotlinx-serialization

---------

Co-authored-by: Daniel Chao <dan.chao@apple.com>
2026-04-15 09:02:42 -07:00
odenix 1ba54f11a9 pkl-parser: Migrate nullness to JSpecify (#1515) 2026-04-14 12:17:17 -07:00
odenix 2d4286ee7b Upgrade JVM toolchain to 25 and Kotlin toolchain to 2.3.20 (#1516)
Motivation
- Enable correct NullAway analysis
- Pick up toolchain fixes and improvements

Toolchains
- Require JDK 25 for JVM toolchain (keep Java 17 runtime compatibility)
- Require Kotlin 2.3.20 for Kotlin toolchain (keep Kotlin 2.2 runtime
compatibility)
- Require JDK 25 for Gradle daemon JVM (via
gradle-daemon-jvm.properties)
- Fix javac and kotlinc warnings from toolchain upgrades

CI
- Bump GitHub workflows to JDK 25

Building Kotlin
- Bump Kotlin language level to 2.2 to match stdlib version
- Consolidate build logic into pklKotlinBase.gradle.kts
- Adopt modern Kotlin plugin syntax
- Fix new kotlinc warnings
- Update ktfmt to 0.62
  - first version compatible with Kotlin 2.3.20
  - changes formatting compared to 0.61
- Replace dependency resolution rule with BOM alignment
  - rule was too broad and interfered with toolchain/runtime separation

Testing
- Expand matrix to JDK 25 (LTS) and 26
- Ensure each matrix task can be run independently
- Fix KotlinCodeGeneratorsTest and EmbeddedExecutorsTest on affected
JDKs
- Disable one test in CliCommandTest on affected JDKs (failure cause
unknown)

Compatibility fixes
- Fix reflective access in DocGenerator on affected JDKs

Build fixes
- Fix misuse of `task.enabled` vs. `report.required`
- Fix `gradlew tasks` on Windows
- Downgrade Spotless to 8.3.0 to (hopefully) work around sporadic
NoClassDefFoundError

Result
- NullAway runs correctly
- Broader JDK test coverage
- More reproducible and potentially faster builds
2026-04-14 11:57:09 -07:00
odenix 4620992743 pkl-parser: Represent "no children" as an empty list instead of null (#1513)
Motivation:
Facilitate the use of the NullAway checker as part of moving to
JSpecify.

Changes:
- represent "no children" as `List.of()` instead of null
- remove obsolete `children != null` assertions
  - NullAway intentionally ignores such assertions
- remove "no children" special-casing where no longer necessary

Result:
- cleaner code with similar performance
- removed a barrier to using the NullAway checker
2026-04-09 08:05:34 -07:00
odenix 99cbd07518 Update GraalVM to 25.0.1 (#1506)
The latest version (25.0.2) no longer supports macos-x64.
2026-04-07 13:21:19 -07:00
odenix 623912eca0 Update msgpack to 0.9.11 and slf4j to 2.x (#1501) 2026-04-06 22:00:07 -07:00
odenix 1251843169 Update Kotlin dependencies (#1498) 2026-04-06 12:06:43 -07:00
odenix 0835c6da82 Update JUnit to 6.x (#1496) 2026-04-06 11:15:55 -07:00
odenix a8c66938e6 Update dependencies (#1492)
Update dependencies by running `./gradlew updateDependencyLocks`. Most
of the updated dependencies are test dependencies.
2026-04-06 08:22:06 -07:00
Luke Daley 8e7eb2bd96 Fix data race in MessagePack encoder for concurrent server sends (#1486) 2026-04-04 14:26:16 -07:00
odenix 58033598c7 Fix Javadoc and kotlinc warnings (#1490) 2026-04-03 14:32:34 -07:00
Jen Basch a9c890e2f9 Do not activate power assertions when a single union member containing a type constraint fails (#1462)
Prior to this change, this code would activate powers assertions /
instrumentation permanently:
```pkl
foo: String(contains("a")) | String(contains("b")) = "boo"
```

This is because the `contains("a")` constraint would fail, triggering
power assertions, but the subsequent check of the union's
`contains("b")` branch would succeed.
As observed in #1419, once instrumentation is enabled, all subsequent
evaluation slows significantly.
As with #1419, the fix here is to disable power assertions via
`VmLocalContext` until we know that all union members failed type
checking; then, each member is re-executed with power assertions allowed
to provide the improved user-facing error.
2026-03-25 11:52:37 -07:00
Jen Basch cdc6fa8aec Prevent I/O when checking UNC paths against --root-dir (#1466)
Test on [windows] please
2026-03-25 11:40:51 -07:00
Jen Basch 1104f12362 Allow custom/external resources to be "not found" (#1471)
This allows custom/external resources to produce `null` values for
nullable reads (`read?`)

Ref: https://github.com/apple/pkl-go/issues/157
2026-03-24 12:43:44 -07:00
Jen Basch cce84d7ccc Correct SecurityManager check for HTTP(S) module URIs (#1463) 2026-03-23 07:43:07 -07:00
Jen Basch a6db476c70 Fix module reflection when instrumentation is active (#1464) 2026-03-23 07:42:40 -07:00
Kushal Pisavadia f9b880be85 Fix command typealias unwrapping in resolveType (#1449)
The loop unwraps nullables and constraints but breaks straight away
after a `typealias`. This means the nullable is missed. Removing the
`break` fixes it.

## Exception

```
org.pkl.core.PklException: –– Pkl Error ––
Command option property `foo` has unsupported type `String?`.

11 | foo: OptionalString
     ^^^^^^^^^^^^^^^^^^^
at <unknown> (file:///var/folders/xh/lmp1n6qj4m13t53cfmbqnkwh0000gn/T/junit-1378070630576324311/cmd.pkl)

Use a supported type or define a transformEach and/or transformAll function
```
2026-02-27 13:33:00 -08:00
Kushal Pisavadia 64ea7951db Fix stream double-consumption in CommandSpecParser (#1448)
The `choices` stream was consumed eagerly for metavar construction, then
captured in a lambda for later validation—which promptly fell over with
`IllegalStateException`. Materialise to a `List` straightaway.
2026-02-27 10:04:32 +00:00
Islon Scherer cac3e483b5 Start next dev iteration 2026-02-26 09:51:27 -08:00
Islon Scherer 4d35f18309 Prepare 0.31.0 release 2026-02-26 09:51:27 -08:00
Jen Basch 4cf2a1b42c Allow command options to have nullable types and default values (#1444) 2026-02-26 08:34:46 -08:00
Jen Basch 3ef065b6b6 Correct --root-dir check to also work for jar:file: URIs (#1442) 2026-02-25 10:57:01 -08:00
Jen Basch be21c34938 Allow command transformAll functions to perform imports (#1440) 2026-02-25 08:03:53 -08:00
Jen Basch 12915f520f Fix command error and import handling (#1436) 2026-02-24 08:09:25 -08:00
Jen Basch a5dc91f0a5 Command flag behavior improvements (#1432)
* Forbid overlap of built-in and command-defined flag names 
* Allow interleaving built-in and command-defined flags on the command
line
* List abbreviated flag names first, matching the behavior of built-in
flags
2026-02-20 12:00:18 -08:00
Jen Basch 08712e8b26 Fix display of evaluation errors thrown by command convert/transformAll (#1431) 2026-02-20 07:51:33 -08:00
Jen Basch 72a57af164 SPICE-0025: pkl run CLI framework (#1367) 2026-02-12 07:53:02 -08:00
Islon Scherer 60f628eb36 Fix possible race condition during module and resource reading (#1426) 2026-02-11 11:18:11 +01:00
Islon Scherer f0449c8330 Add flag to turn power assertions on/off (#1419) 2026-02-03 09:35:16 +01:00
Jen Basch 73264e8fd1 SPICE-0024: Annotation converters (#1333)
This enables defining declarative key and/or value transformations in
cases where neither `Class`- nor path-based converters can be applied
gracefully. It is also the only way to express transforming the
resulting property names in `Typed` objects without applying a converter
to the entire containing type, which is cumbersome at best.

SPICE: https://github.com/apple/pkl-evolution/pull/26
2026-01-23 12:44:41 -08:00
Daniel Chao ed0cad668f Fix Function.toString (#1411)
Fixes an issue where the underlying default Java toString() is leaking
through
2026-01-21 07:29:58 -08:00
Daniel Chao 03a7676e64 Implement power assertions (#1384)
This adds power assertions to Pkl!

This implements the SPICE described in
https://github.com/apple/pkl-evolution/pull/29

This follows the power assertions style of reporting also found in
Groovy, Kotlin, and others.

* Literal values are not emitted in the diagram
* Stdlib constructors of literals like `List(1, 2)` are also considered
  literals

Power assertions are added to:

* Failing type constraints
* Failing test facts

Power assertions are implemented as a truffle instrument to observe
execution.
When an assertion fails, the instrument is created and the assertion is
run again to observe facts.
This incurs runtime overhead to collect facts, but has no impact on code
in the non-error case.

---------

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-01-20 21:41:33 -08:00
Daniel Chao 3cd294b62a Add 'let' to list of control keywords (#1409)
Small improvement to syntax highlighting
2026-01-19 20:00:21 -08:00
Akshat Anand 9d385f2194 Fix super method call inside let expression (#1383)
Fixes #1309

The issue was that super calls were blocked inside let expressions
because:
1. The compiler's isClassMemberScope() check didn't skip over lambda
scopes created by let expressions
2. The runtime's findSupermethod() didn't traverse past VmFunction
owners to find the actual class prototype

Changes:
- SymbolTable.java: Updated isClassMemberScope() to skip lambda scopes
before checking if the parent is a class or module scope
- InvokeSuperMethodNode.java: Updated findSupermethod() to skip
VmFunction owners when looking for the class prototype

Added regression tests covering:
- Super method calls inside let expressions
- Super property access inside let expressions
- Nested let expressions with super calls

---------

Co-authored-by: Jen Basch <jbasch@apple.com>
2026-01-09 19:59:20 -08:00
Daniel Chao ac4f2fd9a6 Add isNotEmpty, isNotBlank methods (#1396)
Adds convenience methods `isNotEmpty` and `isNotBlank`. This borrows the
same methods from Kotlin.

This helps users write more fluent constraints, for example,
`foo.isNotEmpty.implies(bar)`.

Adds:

* List#isNotEmpty
* Map#isNotEmpty
* Set#isNotEmpty
* Mapping#isNotEmpty
* Listing#isNotEmpty
* String#isNotEmpty
* String#isNotBlank
2026-01-08 13:22:43 -08:00
Daniel Chao 14d58a17b0 Address warning diagnostics (#1395)
This addressess various warning diagnostics throughout the codebase.
2026-01-07 22:11:24 -08:00
Daniel Chao 6b9c670cfd Add syntax highlighting of Pkl code (#1385)
This adds syntax highlighting of Pkl code!

It adds highlighting for:

* Stack frames within error messages
* CLI REPL (highlights as you type, highlights error output)
* Power assertions (coming in https://github.com/apple/pkl/pull/1384)

This uses the lexer for highlighting. It will highlight strings,
numbers, keywords, but doesn't understand how to highlight nodes like
types, function params, etc.
The reason for this is because a single line of code by itself may not
be grammatically valid.
2026-01-06 10:33:11 -08:00
Daniel Chao 4f4f03dbca Fix cacheing of module type (#1393)
This fixes an issue where the `module` type is incorrectly cached.
2026-01-05 14:49:07 -08:00
Daniel Chao 8f83885c75 Fix default value for non-final module type (#1392)
This fixes an issue where the `module` type produces the wrong default
value.

Closes #1391
2026-01-05 11:39:24 -08:00
Islon Scherer 41cf485ffb Fix bug in parsing of super expression (#1364) 2025-12-12 18:02:48 +01:00
Daniel Chao 53f3be64f3 Fix parsing of URLs with plus signs (#1335)
This fixes an issue where URLs with schemes that contain `+`, `-`, and
`.` would not be parsed correctly.

For example, `foo+bar:///?baz.pkl` would turn into
`foo+bar:///%3Fbaz.pkl`. The query param is lost, and turned into the
path.
2025-12-03 10:11:23 -08:00
Jen Basch d1c652f736 Vendor paguro's RrbTree, fix an int overflow breaking large Lists (#1337) 2025-12-03 09:02:17 -08:00
Spencer Phillip Young cc02b6b685 Fix newline checks in parser (#1328) 2025-11-24 14:40:54 +01:00
Spencer Phillip Young ba281e8475 Fix empty parenthesized type unexpected error (#1323) 2025-11-18 15:35:44 +01:00
Dan Chao 4d70baba86 Start next dev iteration 2025-11-03 12:26:58 -08:00
Dan Chao 7f231cd916 Prepare 0.30.0 release 2025-11-03 12:26:58 -08:00
Jen Basch ffc9167bf5 Switch yaml.Parser to parse binary scalars as Bytes (#1277) 2025-10-30 16:45:59 -07:00