Skip to content

When the wrapConditionals option is active, props cannot be read from outside of owners #2626

@AFatNiBBa

Description

@AFatNiBBa

Describe the bug

In the attached playground, due to the wrapConditionals compiler option, this expression

wrap() ? n() * 2 : n()

Gets turned into

_$memo(() => !!wrap())() ? n() * 2 : n()

Which means that if the prop is read from outside an owner, that memo will never be disposed

Your Example Website or App

https://playground.solidjs.com/anonymous/453940c4-6eca-4afd-9f30-00dd75aab1cb

Steps to Reproduce the Bug or Issue

  1. Open the playground
  2. Press "Increase"
  3. (In the console, notice that the memo has a parent owner)
  4. Press the second button
  5. (In the console, notice that the memo has NOT a parent owner)

Expected behavior

The memo should not be created if there's no owner.
Maybe a special version of createMemo() (That just calls the function when there's no owner) should be used

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chromium Edge
  • Version: 146.0.3856.59

Additional context

I used the console.log() to detect whether the memo had a parent owner because I don't know how to turn warnings on the playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions