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!
🔄 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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 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:
main← Head:double-invert-fix📝 Commits (1)
518a832Fix double unary minus📊 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
AstBuilderis processingUnaryMinus -> [Parenthesized]* -> UnaryMinus -> IntLiteral, the "inner"UnaryMinushelpfully defers inversion to theIntLiteraland 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-mostUnaryMinusto 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.