Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex String interpolation fails (silently) #867

Open
nikeokoronkwo opened this issue Dec 23, 2024 · 3 comments
Open

Regex String interpolation fails (silently) #867

nikeokoronkwo opened this issue Dec 23, 2024 · 3 comments

Comments

@nikeokoronkwo
Copy link

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
@HT154
Copy link
Contributor

HT154 commented 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?

@nikeokoronkwo
Copy link
Author

nikeokoronkwo commented Dec 23, 2024 via email

@odenix
Copy link
Contributor

odenix commented Dec 23, 2024

The "unexpected error" message is clearly a bug (possibly fixed by #837).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants