Closed Bug 1611876 Opened 4 years ago Closed 4 years ago

Wrong message for TypeError

Categories

(Core :: JavaScript Engine, defect, P2)

74 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: _, Assigned: arai)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0

Steps to reproduce:

I executed:

a = {}
b = {}
a.c.d = b.e

Tested on 74.0a1 (2020-01-27) (64-bit) on Fedora 31.

Actual results:

I got the error: TypeError: can't access property "d", b.e is undefined

Expected results:

I expect the error: TypeError: can't access property "d", a.c is undefined

Another example, which gives an expected error message is:

a = {}
b = {}
a.c.d = ""

It gives the error message: TypeError: can't access property "d", a.c is undefined

Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Ever confirmed: true
Product: Firefox → Core

This is caused by the confusion between 2 undefined values on the stack, while decompiling the value for error report.
in the example code, b.e is also undefined and is top of the stack, so DecompileValueGenerator finds it and returns decompiled string for it.

we might be able to specify where to search in the stack, depending on the current operation.

Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Priority: -- → P2
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/fc5a0b479615
Specify the stack index for decompilation when reporting null or undefined property access. r=jwalden
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: