[PR #697] [MERGED] Fix double unary minus #677

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

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/697
Author: @HT154
Created: 10/16/2024
Status: Merged
Merged: 10/17/2024
Merged by: @bioball

Base: mainHead: double-invert-fix


📝 Commits (1)

📊 Changes

5 files changed (+16 additions, -4 deletions)

View changed files

📝 pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java (+4 -4)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/basic/float.pkl (+4 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/basic/int.pkl (+4 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/output/basic/float.pcf (+2 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/output/basic/int.pcf (+2 -0)

📄 Description

If AstBuilder is processing UnaryMinus -> [Parenthesized]* -> UnaryMinus -> IntLiteral, the "inner" UnaryMinus helpfully defers inversion to the IntLiteral and returns it directly. The "outer" UnaryMinus, none the wiser, then does the exact same thing. There needs to be a way to force only the inner-most UnaryMinus to delegate to the literal node, which seems tricky in context.

This is my naive attempt at that, but this feels messy. More than happy to take suggestions on a better way to do this!

Resolves #650


🔄 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/697 **Author:** [@HT154](https://github.com/HT154) **Created:** 10/16/2024 **Status:** ✅ Merged **Merged:** 10/17/2024 **Merged by:** [@bioball](https://github.com/bioball) **Base:** `main` ← **Head:** `double-invert-fix` --- ### 📝 Commits (1) - [`518a832`](https://github.com/apple/pkl/commit/518a832eb939c63b82e07bc65efb6220b9c31380) Fix double unary minus ### 📊 Changes **5 files changed** (+16 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java` (+4 -4) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/basic/float.pkl` (+4 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/basic/int.pkl` (+4 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/output/basic/float.pcf` (+2 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/output/basic/int.pcf` (+2 -0) </details> ### 📄 Description If `AstBuilder` is processing `UnaryMinus -> [Parenthesized]* -> UnaryMinus -> IntLiteral`, the "inner" `UnaryMinus` helpfully defers inversion to the `IntLiteral` and returns it directly. The "_outer_" `UnaryMinus`, none the wiser, then does the exact same thing. There needs to be a way to force only the inner-most `UnaryMinus` to delegate to the literal node, which seems tricky in context. This is my naive attempt at that, but this feels messy. More than happy to take suggestions on a better way to do this! Resolves #650 --- <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:06 +01:00
adam closed this issue 2025-12-30 01:26:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#677