Chromium Code Reviews

Unified Diff: src/variables.h

Issue 749633002: harmony-scoping: make assignment to 'const' a late error. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: src/variables.h
diff --git a/src/variables.h b/src/variables.h
index 93bfb4a1816aeb3fb9f370c847ace86da6f2d6b3..aa9c118c3e81961a3299a8dfc928583479a1e28f 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -135,6 +135,20 @@ class Variable: public ZoneObject {
static int CompareIndex(Variable* const* v, Variable* const* w);
+ // Shall an error be thrown if assignment with 'op' operation is perfomed
+ // on this variable in given language mode?
+ bool IsSignallingAssignmentToConst(Token::Value op,
+ StrictMode strict_mode) const {
+ if (mode() == CONST) return op != Token::INIT_CONST;
rossberg 2014/11/25 15:23:36 Hm, wouldn't it be easier and more accurate to imp
Dmitry Lomov (no reviews) 2014/11/25 15:51:01 Hmm, I like my version better since it puts the va
rossberg 2014/11/25 16:25:02 Looks good.
+
+ if (mode() == CONST_LEGACY) {
+ return strict_mode == STRICT && op != Token::INIT_CONST_LEGACY &&
+ op != Token::INIT_CONST;
rossberg 2014/11/25 15:23:36 Can this even occur when mode is CONST_LEGACY?
Dmitry Lomov (no reviews) 2014/11/25 15:51:01 No, done
+ }
+
+ return false;
+ }
+
private:
Scope* scope_;
const AstRawString* name_;

Powered by Google App Engine