Regex String interpolation fails (silently) #260

Closed
opened 2025-12-30 01:22:54 +01:00 by adam · 4 comments
Owner

Originally created by @nikeokoronkwo on GitHub (Dec 23, 2024).

Overview

Apparently, Pkl crashes when Regex inputs have some sort of string interpolation or joining (adding strings together) in the constructor. I understand that Apple Pkl Regex input types are based on Java Regex Syntax, but they support combining strings in the format of a + b + c, while Apple Pkl crashes on either occasions.

Problem

This was the function implemented for this case

local function typeRegex(name: String) Regex = Regex("./src/([A-Za-z]+)/" + name + ".pkl")

And this was the error message received, even without implementing the function (in a variable or item for instance).

An unexpected error has occurred. Would you mind filing a bug report?

Info/Context

  • Pkl Version (via pkl --version): 0.26.1
Originally created by @nikeokoronkwo on GitHub (Dec 23, 2024). ## Overview Apparently, Pkl crashes when `Regex` inputs have some sort of string interpolation or joining (adding strings together) in the constructor. I understand that Apple Pkl `Regex` input types are based on Java Regex Syntax, but they support combining strings in the format of `a + b + c`, while Apple Pkl crashes on either occasions. ## Problem This was the function implemented for this case ```pkl local function typeRegex(name: String) Regex = Regex("./src/([A-Za-z]+)/" + name + ".pkl") ``` And this was the error message received, even without implementing the function (in a variable or item for instance). ```log An unexpected error has occurred. Would you mind filing a bug report? ``` ## Info/Context - Pkl Version (via `pkl --version`): 0.26.1
adam closed this issue 2025-12-30 01:22:54 +01:00
Author
Owner

@HT154 commented on GitHub (Dec 23, 2024):

I'm not able to reproduce this on Pkl 0.27.1 (the current release). Given module:

local function typeRegex(name: String): Regex = Regex("./src/([A-Za-z]+)/" + name + ".pkl")
//                                    ^ note this missing colon from your snippet

x = typeRegex("abc").findMatchesIn("./src/abcDEF/abc.pkl").length
y = typeRegex("abc").findMatchesIn("./src/abcDEF/def.pkl").length

As expected, this evaluates to:

x = 1
y = 0

Can you try again on the latest release? If you're still seeing issues, can you share a more complete repro?

@HT154 commented on GitHub (Dec 23, 2024): I'm not able to reproduce this on Pkl 0.27.1 (the current release). Given module: ```pkl local function typeRegex(name: String): Regex = Regex("./src/([A-Za-z]+)/" + name + ".pkl") // ^ note this missing colon from your snippet x = typeRegex("abc").findMatchesIn("./src/abcDEF/abc.pkl").length y = typeRegex("abc").findMatchesIn("./src/abcDEF/def.pkl").length ``` As expected, this evaluates to: ```pkl x = 1 y = 0 ``` Can you try again on the latest release? If you're still seeing issues, can you share a more complete repro?
Author
Owner

@nikeokoronkwo commented on GitHub (Dec 23, 2024):

Oh, my bad. Must've been the colon
Sorry about that

@nikeokoronkwo commented on GitHub (Dec 23, 2024): Oh, my bad. Must've been the colon Sorry about that
Author
Owner

@odenix commented on GitHub (Dec 24, 2024):

The "unexpected error" message is clearly a bug (possibly fixed by https://github.com/apple/pkl/pull/837).

@odenix commented on GitHub (Dec 24, 2024): The "unexpected error" message is clearly a bug (possibly fixed by https://github.com/apple/pkl/pull/837).
Author
Owner

@bioball commented on GitHub (Jan 17, 2025):

I haven't been able to reproduce this; closing this. Please comment if you are still seeing this.

@bioball commented on GitHub (Jan 17, 2025): I haven't been able to reproduce this; closing this. Please comment if you are still seeing this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#260