Commit 9e482baf authored by caitpotter88's avatar caitpotter88 Committed by Commit bot

[parser] better error message for generator constructors

BUG=
LOG=N
R=arv@chromium.org

Review URL: https://codereview.chromium.org/982153003

Cr-Commit-Position: refs/heads/master@{#27051}
parent 6f946d6c
......@@ -8,7 +8,8 @@ var kMessages = {
// Error
cyclic_proto: ["Cyclic __proto__ value"],
code_gen_from_strings: ["%0"],
constructor_special_method: ["Class constructor may not be an accessor"],
constructor_is_generator: ["Class constructor may not be a generator"],
constructor_is_accessor: ["Class constructor may not be an accessor"],
// TypeError
generator_running: ["Generator is already running"],
unexpected_token: ["Unexpected token ", "%0"],
......
......@@ -3106,7 +3106,9 @@ void ParserBase<Traits>::ClassLiteralChecker::CheckProperty(
}
} else if (IsConstructor()) {
if (is_generator || type == kAccessorProperty) {
this->parser()->ReportMessage("constructor_special_method");
const char* msg =
is_generator ? "constructor_is_generator" : "constructor_is_accessor";
this->parser()->ReportMessage(msg);
*ok = false;
return;
}
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-classes
'use strict';
class C {
get constructor() {}
}
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:9: SyntaxError: Class constructor may not be an accessor
get constructor() {}
^^^^^^^^^^^
SyntaxError: Class constructor may not be an accessor
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-classes
'use strict';
class C {
*constructor() {}
}
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:9: SyntaxError: Class constructor may not be a generator
*constructor() {}
^^^^^^^^^^^
SyntaxError: Class constructor may not be a generator
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment