New issue
Advanced search Search tips

Issue 7154 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
HW: ----
NextAction: ----
OS: ----
Priority: 3
Type: FeatureRequest

Blocking:
issue 6513



Sign in to add a comment

TypeError message about read only property does not respect Symbol.toStringTag in presence of null in prototype chain

Reported by dmitry.k...@gmail.com, Dec 3 2017

Issue description

Version: 6.1.534.42
OS: Windows
Architecture: x64

What steps will reproduce the problem?
1. Run the following code

  class Null {
    constructor() { Object.freeze(this) }
    get [Symbol.toStringTag]() { return 'Null' }
  }
  Object.setPrototypeOf(Null.prototype, null)
  const n = new Null()
  n.prop = 42


What is the expected output?

Expected TypeError message to say:
Cannot assign to read only property 'prop' of object '[object Null]'


What do you see instead?

The message says:
Cannot assign to read only property 'prop' of object '[object Object]'



 
Components: Language
Labels: -Type-Bug Priority-3 Type-FeatureRequest
Status: Available (was: Untriaged)

Comment 2 by adamk@chromium.org, Dec 11 2017

Blocking: 6513

Comment 3 by caitp@chromium.org, Dec 11 2017

This is from using Object::NoSideEffectsToString() for formatting messages, rather than Object.prototype.toString(), which ignores accessors.

There's a good reason to not do effectful things in this, so do we actually want to fix this? The application could fix it for debug purposes by adding Symbol.toStringTag as a data property of the class prototype.

An alternative would be to guess the correct O.p.toStringTag value from the name of the object's constructor (if any), which I believe we can get unobservably from Map::constructor_or_backpointer?

Comment 4 by caitp@chromium.org, Dec 11 2017

I sent out https://chromium-review.googlesource.com/c/v8/v8/+/820292 as a strawman fix, but anyone should free to take over if the like

Sign in to add a comment