New issue
Advanced search Search tips
Starred by 1 user

Issue metadata

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

issue 6513

Sign in to add a comment

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

Reported by, 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]'

Comment 1 by, Dec 11 2017

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

Comment 2 by, Dec 11 2017

Blocking: 6513

Comment 3 by, 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, Dec 11 2017

I sent out as a strawman fix, but anyone should free to take over if the like

Sign in to add a comment