From 397183a6200f391b81ea8fe21e12951a75c1339b Mon Sep 17 00:00:00 2001 From: Jen Basch Date: Thu, 17 Sep 2026 12:52:53 -0700 Subject: [PATCH] Mark overridable `external` properties as `const` (#1864) --- docs/modules/release-notes/pages/0.33.adoc | 13 +++++++++ stdlib/math.pkl | 34 +++++++++++----------- stdlib/release.pkl | 2 +- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/docs/modules/release-notes/pages/0.33.adoc b/docs/modules/release-notes/pages/0.33.adoc index 32337e92a..766e1eb53 100644 --- a/docs/modules/release-notes/pages/0.33.adoc +++ b/docs/modules/release-notes/pages/0.33.adoc @@ -69,6 +69,19 @@ A `Class` value typechecked against `Class` must be a subclass of `T`. If `T` does not resolve to a class type (i.e. it is a union type, nullable type, string literal type, parameterized type, or `nothing`), the type check will always fail. +=== Standard library `external` module properties are now marked `const` + +Previously, module properties in `pkl:math` and `pkl:release` could be overriden by amending the module. +Doing this makes little sense—these value are constants and overriding them by amending their module would be odd. + +This is a breaking change for code that looks like this: +[source,pkl] +---- +bogusMath = (import("pkl:math")) { + minInt = -1 +} +---- + === XXX == Bug Fixes [small]#🐜# diff --git a/stdlib/math.pkl b/stdlib/math.pkl index 448016679..05afaed58 100644 --- a/stdlib/math.pkl +++ b/stdlib/math.pkl @@ -22,63 +22,63 @@ module pkl.math /// The minimum [Int] value: `-9223372036854775808`. -external minInt: Int +external const minInt: Int /// The minimum [Int8] value: -128. -external minInt8: Int8 +external const minInt8: Int8 /// The minimum [Int16] value: -32768. -external minInt16: Int16 +external const minInt16: Int16 /// The minimum [Int32] value: -2147483648. -external minInt32: Int32 +external const minInt32: Int32 /// The maximum [Int] value: `9223372036854775807`. -external maxInt: Int +external const maxInt: Int /// The maximum [Int8] value: 127. -external maxInt8: Int8 +external const maxInt8: Int8 /// The maximum [Int16] value: 32767. -external maxInt16: Int16 +external const maxInt16: Int16 /// The maximum [Int32] value: 2147483647. -external maxInt32: Int32 +external const maxInt32: Int32 /// The maximum [UInt] value: 9223372036854775807. /// /// Note that [maxUInt] is equal to [maxInt], /// not `maxInt * 2 + 1` as one might expect. /// That is, [UInt] has half the range of [Int]. -external maxUInt: UInt +external const maxUInt: UInt /// The maximum [UInt8] value: 255. -external maxUInt8: UInt8 +external const maxUInt8: UInt8 /// The maximum [UInt16] value: 65535. -external maxUInt16: UInt16 +external const maxUInt16: UInt16 /// The maximum [UInt32] value: 4294967295. -external maxUInt32: UInt32 +external const maxUInt32: UInt32 /// The minimum finite [Float] value: `-1.7976931348623157e308`. /// /// Operations whose value is less than [minFiniteFloat] return -[Infinity]. -external minFiniteFloat: Float +external const minFiniteFloat: Float /// The maximum finite [Float] value: `1.7976931348623157e308`. /// /// Operations whose value is greater than [maxFiniteFloat] return [Infinity]. -external maxFiniteFloat: Float +external const maxFiniteFloat: Float /// The minimum positive [Float] value that is greater than zero: `4.9e-324`. -external minPositiveFloat: Float +external const minPositiveFloat: Float /// The number [e](https://en.wikipedia.org/wiki/E_(mathematical_constant)). -external e: Float +external const e: Float /// The number [π](https://en.wikipedia.org/wiki/Pi). -external pi: Float +external const pi: Float /// Returns e [raised to the power](https://en.wikipedia.org/wiki/Exponential_function) of /// [exponent]. diff --git a/stdlib/release.pkl b/stdlib/release.pkl index e0765fd00..f27281ef7 100644 --- a/stdlib/release.pkl +++ b/stdlib/release.pkl @@ -21,7 +21,7 @@ module pkl.release import "pkl:semver" /// The Pkl release that the current program runs on. -external current: Release +external const current: Release /// A Pkl release. class Release {