Skip to content
This repository was archived by the owner on Oct 11, 2026. It is now read-only.
This repository was archived by the owner on Oct 11, 2026. It is now read-only.

incorrect diagnostic: using a '.' after a '?.' might fail #1192

Closed

Description

@vegerot

minimal example:

undefined?.a.b

quick-lint reports: using a '.' after a '?.' might fail, since '?.' might return 'undefined'., however this is not true.

Running the above code shows that optional chaining short-circuits the entire property access expression to undefined, not just the first property access.

❯ deno
Deno 1.39.4
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> undefined?.a.b.c.d
undefined

idk if there's a "correct" version of this diagnostic, or if we should just delete the whole thing

Activity

  1. vegerot commented on Jan 23, 2024

    @vegerot
    SponsorContributorAuthor

    A better version of this diagnostic would be to check for non-null assertions, which are incorrect.

    undefined?.a!.b
  2. added this to the 3.2 milestone on Jan 25, 2024
  3. self-assigned this
    on Jan 25, 2024
  4. strager commented on Jan 25, 2024

    @strager
    Collaborator

    Fixed in Git commit 434d085. I will ship the fix in version 3.2.0.

  5. strager commented on Mar 4, 2024

    @strager
    Collaborator

    Fix released in version 3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions