Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: sdk/lib/_internal/compiler/implementation/js/nodes.dart

Issue 255843005: Avoid generating VariableUse nodes with non-identifier names (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/js/nodes.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js/nodes.dart b/sdk/lib/_internal/compiler/implementation/js/nodes.dart
index 451d1f60ba8cbcaf6555b072493e6172383ace68..d19ae570374b7285b0c73088aea1b23fe04a5958 100644
--- a/sdk/lib/_internal/compiler/implementation/js/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/nodes.dart
@@ -799,9 +799,10 @@ class Postfix extends Expression {
abstract class VariableReference extends Expression {
final String name;
- // We treat operators as if they were special functions. They can thus be
- // referenced like other variables.
- VariableReference(this.name);
+ VariableReference(this.name) {
+ assert(_identifierRE.hasMatch(name));
+ }
+ static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
accept(NodeVisitor visitor);
int get precedenceLevel => PRIMARY;
@@ -827,7 +828,7 @@ class VariableDeclaration extends VariableReference {
}
class Parameter extends VariableDeclaration {
- Parameter(String id) : super(id);
+ Parameter(String name) : super(name);
accept(NodeVisitor visitor) => visitor.visitParameter(this);
Parameter _clone() => new Parameter(name);

Powered by Google App Engine
This is Rietveld 408576698