Skip to content

Unexpected this !== undefined in strict mode when variable declared before 'use strict' #58510

@kevgeoleo

Description

@kevgeoleo

Version

v24.1.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

Hi,
I wanted to report a bug which can be reproduced by running the following snippet:

function f() {
  var obj = "foo" //if you comment this and run, you will get same result as bun and deno in node
  "use strict";

  return this === undefined;
}
console.log(f());   // node : false  deno and bun : true

How often does it reproduce? Is there a required condition?

No specific condition

What is the expected behavior? Why is that the expected behavior?

true

What do you see instead?

false

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions