Skip to content

v4.18.1

Latest

Choose a tag to compare

@lahma lahma released this 23 Nov 06:09
· 975 commits to main since this release
f170b5d

Jint 4.18.1 is a patch release from the 4.x branch. It backports correctness and conformance fixes from main: 17 pull requests since 4.18.0, with no new public API. Several of them change what a script observes, because Jint now does what the specification says where it did not; What might change for you below lists them.

Highlights

Five spec deviations, reported together (#4581, from #4580; issue #4579, reported by @trackoor).

  • A binding named undefined is read, not folded to the global value: (function (undefined) { return undefined; })('s') returns 's'.
  • { "__proto__": proto } sets the prototype, as { __proto__: proto } already did.
  • parseFloat('1e5.5') stops at the second point and returns 100000.
  • An integral number above 2^53 converts to its shortest spelling: String(2 ** 60) is "1152921504606847000".
  • forEach, every, flatMap and the other array generics read the array as it is after a callback unshifts into it.

Strings.

  • String iteration steps by code point, not by grapheme cluster, in spread, for...of, Array.from, destructuring, Iterator.from and Array.fromAsync: [...'\r\n'].length is 2 (#4694, from #4688; issue #4228, reported by @mkromann).
  • String.raw converts an undefined substitution instead of dropping it, and < on two objects compares the primitives it already converted instead of converting again (#4659, from #4658; issue #4613, reported by @trackoor).

Intl.Segmenter follows Unicode UAX #29, from a pinned Unicode 17.0 table, the same on every target framework: sentence (#4675, from #4672), word (#4690, from #4686; issue #4683) and grapheme granularity (#4693, from #4691). Segments.prototype.containing finds its segment by binary search (#4720, from #4719).

Limits a host configured hold in more places. Options.Constraints.MaxArraySize now bounds toSorted, toReversed, with and sort, and Array.from, Iterator.prototype.toArray and its async form, which close their iterator when the limit is passed rather than drain an endless source first (#4676, from #4665; issue #4520).

Typed arrays and property definitions.

  • A typed array over an immutable ArrayBuffer follows the proposal's internal methods: its elements are non-writable and non-configurable, defineProperty accepts only a restatement of them, and an assignment is refused before its value is converted (strict code throws a TypeError, sloppy code does nothing) (#4730, from #4729).
  • Redefining a property's 0 as -0 is a change of value: a non-writable property refuses it and a writable one stores it (#4730, from #4729).

Hosts and interop.

  • Overload resolution no longer throws and catches an exception for each candidate an argument cannot convert to, a cost that every such call had paid since 4.16.2 (#4728, from #4727; issue #4337, reported by @RonenNess).
  • On .NET Framework and netstandard, a System.Text.Json JsonValue crosses as the primitive it holds, and a JsonObject or JsonArray stringifies without a cyclic-reference error; on .NET 8 and later, a JsonValue around a CLR object no longer overflows the stack (#4689, from #4685; issue #4681).
  • DisposableStack and AsyncDisposableStack methods use the built-in's own realm (#4671, from #4663).

Reading undefined in unprepared code stays as fast as in 4.18.0. The first fix above made every read of undefined that the static analysis did not fold resolve through the scope chain, and code run through Execute(string) is never analysed. Two changes close that again. Read-only globals such as undefined, NaN and Infinity are now served from the global-binding cache (#4732, from #4731). And a read of undefined that has resolved to the global is folded at run time, the way the analysis folds it, with fused x === undefined and x == undefined comparisons; the fold is undone wherever a binding of that name can appear later (#4735, from #4734).

Temporal. Temporal.Duration.from('P1DT') is rejected, and a PlainMonthDay with a year past int.MaxValue keeps that year's leap status (#4674, from #4669).

Build and tests. The branch builds with the .NET 11 SDK (#4718, from #4373), and a stack-guard test no longer flakes on an exact-depth comparison (#4716, from #3140).

What might change for you

  • A local binding named undefined is now read. A script that declares one, as a parameter, a var or a catch parameter, sees its value where it used to see the global undefined.
  • Iterating a string yields code points. A CRLF, a letter and its combining mark, or an emoji sequence joined by U+200D is now several elements of [...s] or for (const c of s), as in every other engine.
  • Intl.Segmenter results change wherever the previous segmentation differed from UAX #29.
  • MaxArraySize, when set, now stops toSorted, with and the other copying methods and the iterator collections with the same error other arrays past it raise.
  • An assignment to an element of a typed array over an immutable buffer no longer throws in sloppy code.
  • A System.Text.Json JsonValue on .NET Framework and netstandard reaches script as a string, number or boolean instead of a wrapped object.

Verification

Every backport was verified failing-first: its tests ran against the unfixed 4.x tree on .NET 10 and .NET Framework 4.7.2, then again with the change. The release candidate was measured against 4.18.0 in paired rounds, alternating which build ran first in each round.

  • SunSpider and Dromaeo, all 50 rows: six rounds against the candidate before #4735 and three against the final one found no regression. Two rows were slower in all three rounds of the second run, math-cordic and bitops-nsieve-bits. Six more paired rounds put them at +0.70% [−0.84, +2.36] and −2.12% [−4.36, +5.86], so both 95% intervals include zero.
  • Reads of undefined in unprepared code: neither suite reads undefined, so a targeted benchmark measured it. Before #4735 the candidate was 10–30% slower than 4.18.0 on those reads. The final candidate reads +0.12%, +0.05% and −0.67% against 4.18.0, every 95% interval includes zero, and its control rows are unchanged.

What's Changed

  • [4.x] Fix five spec deviations from #4579 (backport of #4580) by @lahma in #4581
  • [4.x] Convert undefined String.raw substitutions and compare the converted primitives in IsLessThan (backport of #4658) by @lahma in #4659
  • [4.x] Use the built-in's own realm in DisposableStack and AsyncDisposableStack methods (backport of #4663) by @lahma in #4671
  • [4.x] Reject a dangling duration time designator and keep a huge PlainMonthDay year's leap status (backport of #4669) by @lahma in #4674
  • [4.x] Intl.Segmenter sentence granularity follows UAX #29 (backport of #4672) by @lahma in #4675
  • [4.x] Bound toSorted, toReversed, with, sort and the iterator collections by MaxArraySize (backport of #4665) by @lahma in #4676
  • [4.x] On .NET Framework and netstandard, a System.Text.Json JsonValue crosses as the primitive it holds (backport of #4685) by @lahma in #4689
  • [4.x] Intl.Segmenter: word segmentation follows UAX #29 WB1-WB999 (backport of #4686) by @lahma in #4690
  • [4.x] Intl.Segmenter: grapheme clusters follow UAX #29 GB1-GB999 on every target framework (backport of #4691) by @lahma in #4693
  • [4.x] Iterate a string by code point, not by grapheme cluster (backport of #4688) by @lahma in #4694
  • [4.x] Detect a stack-guard unwind leak by its march, not by depth spread (backport of #3140) by @lahma in #4716
  • [4.x] Find the segment Segments.prototype.containing asks for by binary search (backport of #4719) by @lahma in #4720
  • [4.x] Build with the .NET 11 SDK (backport of #4373) by @lahma in #4718
  • [4.x] Score an overload without throwing when a number, string or boolean cannot convert (backport of #4727) by @lahma in #4728
  • [4.x] Refuse writes to a typed array over an immutable buffer, keep -0 distinct from 0 when redefining (backport of #4729) by @lahma in #4730
  • [4.x] Cache read-only globals such as undefined, NaN and Infinity for reads in the global-binding cache (backport of #4731) by @lahma in #4732
  • [4.x] Fold reads of undefined at run time where the static analysis did not (backport of #4734) by @lahma in #4735

Full Changelog: v4.18.0...v4.18.1