Confusing error message when attempting to access private class field.

20 views
Skip to first unread message

chenh...@gmail.com

unread,
Jan 15, 2020, 11:33:11 PM1/15/20
to v8-dev
First I created a test class like this below:

class Test {
 
#x = 'private'
}

And then when I attempted to get that private field "#x":

const test = new Test()
console
.log(test.#x)

I recieved an error like this:

SyntaxError: Private field '#x' must be declared in an enclosing class

I thought that this error message is confusing. A better one could be like this:

SyntaxError: Attempting to access private field '#x" 

Sathya Gunasekaran

unread,
Feb 6, 2020, 11:52:48 AM2/6/20
to v8-...@googlegroups.com, Joyee Cheung

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/f0837372-d8ea-4444-84fc-a6c9d0866656%40googlegroups.com.

Joyee Cheung

unread,
Feb 7, 2020, 12:40:11 AM2/7/20
to v8-dev

I think there was some suggestion similar to `Attempting to access private field '#x'` but we ended up going with the current message instead because we thought this one is less confusing - it points out how the user should fix this (by enclosing it with a class) instead of just why.

On Friday, February 7, 2020 at 12:52:48 AM UTC+8, Sathya Gunasekaran wrote:
On Thu, Jan 16, 2020 at 4:33 AM <chenh...@gmail.com> wrote:
First I created a test class like this below:

class Test {
 
#x = 'private'
}

And then when I attempted to get that private field "#x":

const test = new Test()
console
.log(test.#x)

I recieved an error like this:

SyntaxError: Private field '#x' must be declared in an enclosing class

I thought that this error message is confusing. A better one could be like this:

SyntaxError: Attempting to access private field '#x" 

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-...@googlegroups.com.

HQ Chen

unread,
Feb 11, 2020, 3:21:49 AM2/11/20
to v8-...@googlegroups.com
OK, I see. I will have a look at that issue.

Joyee Cheung <jo...@igalia.com> 于2020年2月7日周五 下午1:40写道:
You received this message because you are subscribed to a topic in the Google Groups "v8-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-dev/vDlefmP-Kko/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/8ffaf5c3-c56b-4727-ae74-4ec1540494c2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages