apple / apple/pkl

Surprising scoping behavior: annotations on class properties cannot see the enclosing class

Open
#1,579 2 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

In this snippet, `qux` is not visible inside `@MyAnnotation { ... }`.

```pkl
class MyClass {
@MyAnnotation { prop = qux }
foo: Int

const qux = 15
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied Pkl snippet and inspect how annotation bodies on class properties resolve names. Trace the scoping rules for `@MyAnnotation { prop = qux }` and compare them with the enclosing class scope. Done means the example can resolve `qux` as the class property, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.