Comments (5)
Currently, there is a bug when mixing entries whose keys are integers with elements. So, the first snippet is incorrect, and is a bug.
This happens because Pkl mistakenly interprets [0] = 2
as "assign to element with index 0", instead of "declare an entry with key 0".
from pkl.
Thank you and I understood.
For the first example, what is the expected value of foo[0]
? Should it return the element with index 0?
from pkl.
Currently, there is a bug when mixing entries whose keys are integers with elements. So, the first snippet is incorrect, and is a bug.
What does [n] = x
mean for Dynamic
? Does it mean the same as for Listing
, the same as for Mapping
, or something else?
from pkl.
Currently, the behavior is: if there is an element at index n
, [n] = x
means: overwrite element at that index. And foo[0]
means either "get element with index 0`, or "get entry with key 0", depending on which exists. In our current model, it is not possible to for entries with number keys to coexist with elements at the same number index.
With our current behavior, I think this should throw with a duplicate member definition error. It doesn't make sense for this to be accepted as one element declaration:
foo { [0] = 2; 3 }
I think there's some room for improvement here. This is surprising:
bar {
1
}
foo = (bar) {
[0] = 0
[1] = 1
[2] = 2
}
This produces:
bar {
1
}
foo {
0
[1] = 1
[2] = 2
}
Possibly, we can change the grammar for "assign to element index N", which might help here. For example, here's some made up syntax:
foo {
amend [0] = 0
}
from pkl.
I think this should throw with a duplicate member definition error.
Is it expected behavior that Pkl raise an error if an entry and an element have the same idnex?
I'm developing a Pkl parser written in Ruby so I post this issue.
from pkl.
Related Issues (20)
- Bug: fatal error when chart location is invalid HOT 7
- Automatic formatting of Pkl files HOT 1
- Stack overflow when parameter name is same as object property name HOT 2
- Type constraints on `typealias`es are evaluated eagerly HOT 3
- Question: Submit to CNCF HOT 3
- `gw buildNative` runs aarch64 tasks on amd64 HOT 1
- Allow overriding Java/Kotlin package name in codegen
- Rendering lists in XML may produce unexpected results HOT 1
- Type constraints are sometimes not enforced. HOT 2
- Unable to create test for non-empty constraint on listing HOT 2
- Add SLSA provenance to your releases
- Disable "Allow merge commits" and "Allow rebase merging" in GitHub UI HOT 3
- Non-constant globbed reads return wrong results
- Reads with same glob pattern return same result even if located in different modules/directories
- better source listing for IntelliJ to include line numbers? HOT 2
- Provide an ability to depend on a local project module from a non-project module
- Feature Request: Add `hcl` format
- [Feature Request] Type parameters for Classes
- Unexpected caching with pkl-go and Evaluator.EvaluateOutputText HOT 1
- Output path placeholders don't expose `ValueRenderer.extension`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkl.