Property name with hypen produces error #120

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

Originally created by @tmanternach on GitHub (Mar 18, 2024).

What are you trying to achieve?
I am trying to use pkl to produce a json file that uses hypens in many property names.

What’s the impact of this bug/feature?
I cannot use pkl to produce this json file.

pkl --version Pkl 0.25.2 (Linux 5.15.0-1050-aws, native)

Test file

test {
        with-hyphen = "test"
}

Running pkl eval -f json file.pkl produces the following error:

No viable alternative at input `-hyphen =`.

Expected behavior

I would expect pkl eval -f json file.pkl to produce the following:

{
  "test": {
    "with-hyphen": "test"
  }
}

Thank you.

Originally created by @tmanternach on GitHub (Mar 18, 2024). **What are you trying to achieve?** I am trying to use pkl to produce a json file that uses hypens in many property names. **What’s the impact of this bug/feature?** I cannot use pkl to produce this json file. `pkl --version` Pkl 0.25.2 (Linux 5.15.0-1050-aws, native) ### Test file ``` test { with-hyphen = "test" } ``` Running `pkl eval -f json file.pkl` produces the following error: ```–– Pkl Error –– No viable alternative at input `-hyphen =`. ``` ### Expected behavior I would expect `pkl eval -f json file.pkl` to produce the following: ``` { "test": { "with-hyphen": "test" } } ``` Thank you.
adam closed this issue 2025-12-30 01:21:06 +01:00
Author
Owner

@odenix commented on GitHub (Mar 18, 2024):

You can use backticks:

 `with-hyphen` = "test"
@odenix commented on GitHub (Mar 18, 2024): You can use backticks: ``` `with-hyphen` = "test" ```
Author
Owner

@tmanternach commented on GitHub (Mar 18, 2024):

Thank you! I swear I tried everything but backticks.

@tmanternach commented on GitHub (Mar 18, 2024): Thank you! I swear I tried everything *but* backticks.
Author
Owner

@StefMa commented on GitHub (Mar 18, 2024):

Same applies BTW for keywords.
E.g

`function` = 2

On Mon, Mar 18, 2024, 6:25 PM Trevor Manternach @.***>
wrote:

Thank you! I swear I tried everything but backticks.


Reply to this email directly, view it on GitHub
https://github.com/apple/pkl/issues/334#issuecomment-2004519697, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ACOBQ67JE3VXJF266WS3RNTYY4PRHAVCNFSM6AAAAABE4AKBB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBUGUYTSNRZG4
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

@StefMa commented on GitHub (Mar 18, 2024): Same applies BTW for keywords. E.g ``` `function` = 2 ``` On Mon, Mar 18, 2024, 6:25 PM Trevor Manternach ***@***.***> wrote: > Thank you! I swear I tried everything *but* backticks. > > — > Reply to this email directly, view it on GitHub > <https://github.com/apple/pkl/issues/334#issuecomment-2004519697>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACOBQ67JE3VXJF266WS3RNTYY4PRHAVCNFSM6AAAAABE4AKBB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBUGUYTSNRZG4> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#120