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.
This skips some unnecessary steps when evaluating annotations that
have no attached object bodies by returning an EmptyObjectLiteralNode
instead of a PropertiesLiteralNode
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
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.
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.
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>
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>
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
This uses native-image to generate a C library for Pkl.
This generated library from native-image is wrapped with our own library,
in `pkl.h`.
This produces a static and a dynamic library for each os/arch variant
that Pkl currently supports.
Co-authored-by: Kushal Pisavadia <kushal.p@apple.com>
Co-authored-by: Jen Basch <jbasch94@gmail.com>
Co-authored-by: Islon Scherer <i_desouzascherer@apple.com>
The expression preamble length was subtracted from endColumn even
when endColumn came from the already-stripped sourceLine.length(),
so multi-line frames got a negative caret width and String.repeat
threw. Apply the offset only to the frame-derived columns.
---------
Co-authored-by: Dan Chao <dan.chao@apple.com>
When following redirects, `RequestRewritingClient` discarded each 3xx
response without closing its body, leaking the underlying connection.
Close the body as soon as we know the status is a redirect and won't
be returned, so the too-many-redirects, missing-`Location`,
invalid-URI and downgrade error paths all release the connection too.
This prevents leaking one `BodyHandlers.ofInputStream()` connection
per hop. Now the code closes the body before following the redirect.
This fixes a regression where local members cannot be seen by the
expression evaluator.
Because variable are now parse-time resolved, this builds a truffle node
by first constructing a synthetic module of all defined local members,
and calls AstBuilder on this synthetic module first.
This changes local asset path resolution so that `..` segments at the
dependency root just resolves to the dependency root.
This makes import resolution work the same between local and remote dependencies.
This changes the following:
1. If given a union type, the member must exist on each member of that type
2. If accessing a member off `Reference<D, Null>`, give a `Reference<D, Null>`
Also:
* Improve error messages thrown during member access.
* Add test around accessing members off of a function type
Stdlib modules are singletons that are shared across multiple evaluators.
This improves thread safety by evaluating its `output.bytes` during
initialization, which initializes truffle nodes (e.g. TypeTestNode),
and also initializes the member cache of the module output of `pkl:base`
This addresses many IDE warnings resulting from the switch to JSpecify.
Also, this changes the behavior of exporting VmObject; there's no place
in our code that does not force a VmObject prior to export, so
the existing logic around handling nullable values has been removed.