Skip to content

Assign to a non-derived private field breaks when a public derived field exists with the same name #15273

Closed
@jkbz64

Description

@jkbz64

Describe the bug

Declaring and assigning to a non-derived private field in a class that has a public derived field with the same name breaks with a Cannot assign to derived state compile error, this seems to be broken by #15228.

<script>
  class X {
    #deps = () => [];
  
    deps = $derived.by(() => {
      return [];
    });		
  		
    constructor(f = () => []) {
      this.#deps = f;
    }
  }
</script>

This was working/compiling correctly in 5.19.9

Reproduction

https://svelte.dev/playground/hello-world?version=5.19.10#H4sIAAAAAAAAA22Oy4rDMAxFf0WoXSQQMvv0Ad3NJwzUWaS2Qg2ubCyl0xDy70MmDcxiNloczr1XE3L3IGzwk0KI8B1zcFCQ80quxAp7H0iwuU6oY1q8BWC1pS4p1fKkoAu7dUL_cRtZiVWwwaPY7JOeDRu2oROBL5gMA-wcJYETFCWcznBtD4sB8KZ7R9k_ydW3sViN3xBAJh0yrz7AXB6MGjW8XgAbWTQPVmMu-j_t5ZbXu5d62-7XEsOz4ePH-1OsUOml2GgeaG7nH6W6CcAxAQAA

Logs

Cannot assign to derived state
https://svelte.dev/e/constant_assignment

System Info

System:
    OS: Linux 6.12 Fedora Linux Asahi Remix 41 (Forty One)
    CPU: (8) arm64 unknown
    Memory: 15.83 GB / 31.12 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.n/bin/node
    Yarn: 1.22.21 - ~/.n/bin/yarn
    npm: 10.7.0 - ~/.n/bin/npm
    pnpm: 10.2.1 - ~/.local/share/pnpm/pnpm
    bun: 1.2.2 - ~/.n/bin/bun

Severity

annoyance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions