[PR #578] [MERGED] Allow to String#toInt() to parse a string including "__" #627

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

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/578
Author: @taichi-ishitani
Created: 7/13/2024
Status: Merged
Merged: 7/15/2024
Merged by: @stackoverflow

Base: mainHead: fix_string_to_int


📝 Commits (1)

  • 3028a4d Allow to toInt() to parse a string including "__"

📊 Changes

3 files changed (+12 additions, -4 deletions)

View changed files

📝 pkl-core/src/main/java/org/pkl/core/stdlib/base/StringNodes.java (+2 -2)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/api/string.pkl (+6 -2)
📝 pkl-core/src/test/files/LanguageSnippetTests/output/api/string.pcf (+4 -0)

📄 Description

A Int literal can include sequence of "_" like below.

a = 1_2__3___

However, String#toInt() method cannot parse such string.

a = "1_2__3__".toInt()

image

This PR is to fix this issue.

Refs: https://github.com/apple/pkl/discussions/577#discussion-6927552


🔄 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/578 **Author:** [@taichi-ishitani](https://github.com/taichi-ishitani) **Created:** 7/13/2024 **Status:** ✅ Merged **Merged:** 7/15/2024 **Merged by:** [@stackoverflow](https://github.com/stackoverflow) **Base:** `main` ← **Head:** `fix_string_to_int` --- ### 📝 Commits (1) - [`3028a4d`](https://github.com/apple/pkl/commit/3028a4d83cf6855a1395187b5f9189984d70176c) Allow to toInt() to parse a string including "__" ### 📊 Changes **3 files changed** (+12 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `pkl-core/src/main/java/org/pkl/core/stdlib/base/StringNodes.java` (+2 -2) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/api/string.pkl` (+6 -2) 📝 `pkl-core/src/test/files/LanguageSnippetTests/output/api/string.pcf` (+4 -0) </details> ### 📄 Description A Int literal can include sequence of "_" like below. ```pkl a = 1_2__3___ ``` However, `String#toInt()` method cannot parse such string. ```pkl a = "1_2__3__".toInt() ``` ![image](https://github.com/user-attachments/assets/05819ba3-a623-44ea-9e5d-0744064a2ac3) This PR is to fix this issue. Refs: https://github.com/apple/pkl/discussions/577#discussion-6927552 --- <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:25:46 +01:00
adam closed this issue 2025-12-30 01:25:49 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#627