apple / apple/pkl-lsp

Missing diagnostic error when amending non-`Object` types

Open
#116 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
89
Forks
21
Avg merge
7h 37m
Merged PRs (30d)
3

Description

### Summary

When assigning a value of the wrong type to a `String`-typed property, the Pkl VS Code extension correctly flags a type mismatch *only* for primitive non‑string values (e.g., booleans), but **fails to flag the error when the incorrect value is an object literal**.

### Example

Given a field:
```pkl
my_property: String
```

This invalid assignment is correctly flagged:
```pkl
my_property = true // type mismatch is highlighted
```

But this invalid assignment is NOT flagged:
```pkl
my_property {
value = true
}
```
The second form assigns an object, which should not be allowed for a `String`-typed property, but the VS Code extension does not report any error.

### Expected Behavior
The language server should report a type mismatch when a `String`-typed property is assigned an object literal.

### Actual Behavior
No diagnostic is shown when assigning an object literal.

### Environment
Extension version: 0.21.0
Pkl version: 0.30.0
VS Code: latest stable

### Steps to Reproduce
1. Create a `.pkl` file with a `String` property.
1. Assign an object literal to it.
1. Observe that no type-checking error is shown.

### Additional Notes
This looks like a missing diagnostic case in the language server’s type checker.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in a .pkl file using a String-typed property and an object literal assignment, then trace the language server's type-checking path for object values. The work is done when the server reports a type-mismatch diagnostic for the object literal, matching the existing diagnostic for primitive values.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.