mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
[PR #879] [MERGED] YamlRenderer: allow all primitive scalar types as map keys
#786
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/879
Author: @HT154
Created: 1/10/2025
Status: ✅ Merged
Merged: 1/14/2025
Merged by: @bioball
Base:
main← Head:yaml-renderer-scalar-keys📝 Commits (1)
f6c23bbYamlRenderer: allow all primitive scalar types as map keys📊 Changes
6 files changed (+101 additions, -10 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java(+11 -1)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/YamlRendererNodes.java(+20 -4)📝
pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java(+3 -3)📝
pkl-core/src/main/resources/org/pkl/core/errorMessages.properties(+8 -2)➕
pkl-core/src/test/files/LanguageSnippetTests/input/api/yamlRenderer8.yml.pkl(+33 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/api/yamlRenderer8.yml(+26 -0)📄 Description
YAML (1.2) explicitly allows any value as a mapping key, just like Pkl! This PR allows all of Pkl's primitive scalars (those that can already be natively rendered in YAML: Int, Float, Boolean, Null) to be rendered as mapping keys by
YamlRenderer.This PR does not attempt to allow non-scalar YAML mapping keys (see Example 2.11 at https://yaml.org/spec/1.2.2/#22-structures). This doesn't appear to be a commonly used YAML feature—I've never seen it in the wild—but may be interesting for Pkl to support. If this is desired, it could be taken on as follow-up work, but it might require significant modifications to
YamlRendererNodes.YamlRenderer.Resolves #878
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.