Skip to content

Runes: Assigning a prop as a default value to another prop instead assigns the getter function #9302

@ariymarkowitz

Description

@ariymarkowitz

Describe the bug

If we have the following inside a component:

let {
  a,
  b = a
} = $props()

console.log(b.toString())

The output is:

() => {
      const props = is_signal(props_obj) ? get(props_obj) : props_obj;
      let value = props[key];
      if (value === void 0 && default_value !== void 0) {
        value = default_value;
      }
      return value;
    }

This raises an interesting question: In this case, do we want b to have a as a dependency, or simply copy the initial value?

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACo2OQQqDMBBFrxJCQQVRuhUVeoZ213QRdZRAzIRkLJTg3WsqtIVuupr3hz_DC3xUGjyvroEbOQOv-MlannN62Bj8HTTBlj0uro-b2vdOWWqFEaRmi47YBTyx0eHMkqKModjPEmHq8lM39asom3BcWdluT2cc1Khg4BW5Bdb87RCL_0poIBYiCJL5PjvWMBlx3eBgHVqfZtFAUI_Go4ZC45R2BeGZnDJTmmVfrr9mt_UJL_lZJSkBAAA=

Logs

No response

System Info

https://svelte-5-preview.vercel.app

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions