[PR #879] [MERGED] YamlRenderer: allow all primitive scalar types as map keys #786

Closed
opened 2025-12-30 01:26:42 +01:00 by adam · 0 comments
Owner

📋 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: mainHead: yaml-renderer-scalar-keys


📝 Commits (1)

  • f6c23bb YamlRenderer: 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.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/879 **Author:** [@HT154](https://github.com/HT154) **Created:** 1/10/2025 **Status:** ✅ Merged **Merged:** 1/14/2025 **Merged by:** [@bioball](https://github.com/bioball) **Base:** `main` ← **Head:** `yaml-renderer-scalar-keys` --- ### 📝 Commits (1) - [`f6c23bb`](https://github.com/apple/pkl/commit/f6c23bbb714f70db1ebdad47920119aab8c0e267) YamlRenderer: allow all primitive scalar types as map keys ### 📊 Changes **6 files changed** (+101 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 Description [YAML (1.2) explicitly allows _any_ value as a mapping key](https://yaml.org/spec/1.2.2/#3211-nodes), 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:26:42 +01:00
adam closed this issue 2025-12-30 01:26:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#786