apple / apple/pkl

default values not being used in mapping when explicitly calling new on Object

Open
#379 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
11.5k
Forks
402
Avg merge
1d 15h
Merged PRs (30d)
20

Description

I created a Mapping with some default values for the object values and in some cases the values get used and in others they don't.

I've created an [example of what I mean here](https://github.com/harryjackson/pkl-example/blob/main/defaults.pkl). The code as is should work if you run

```bash
pkl eval defaults.pkl
```

Note the differences between lines 57 and 61, now comment out line 62 and "pkl eval defaults.pkl" fails. Can someone explain the reason the explicit call to "new Service.ServicePort" means the defaults are no longer used?

```bash
57 [8086] = new {
58 port = 8086
59 targetPort = port
60 }
61 [8081] = new Service.ServicePort {
62 //name = "debug"
63 port = 8081
64 targetPort = port
65 }
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked defaults.pkl example and run `pkl eval defaults.pkl`. Compare the object at lines 57–60 with the explicit `new Service.ServicePort` at lines 61–65, then comment or uncomment line 62 to reproduce the difference. Done means explaining or correcting why the explicit constructor changes default-value handling.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.