Reviewed by Darin.
Bug 20293: Crash in JavaScript codegen for eval("const a;")
<https://bugs.webkit.org/show_bug.cgi?id=20293>
Correctly handle constant declarations in eval code with no initializer.
JavaScriptCore:
* kjs/nodes.cpp:
(KJS::ConstDeclNode::emitCodeSingle):
LayoutTests:
* fast/js/const-expected.txt:
* fast/js/resources/const.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35584
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-08-05 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Darin.
+
+ Bug 20293: Crash in JavaScript codegen for eval("const a;")
+ <https://bugs.webkit.org/show_bug.cgi?id=20293>
+
+ Correctly handle constant declarations in eval code with no initializer.
+
+ * kjs/nodes.cpp:
+ (KJS::ConstDeclNode::emitCodeSingle):
+
2008-08-05 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Oliver.
// FIXME: While this code should only be hit in eval code, it will potentially
// assign to the wrong base if m_ident exists in an intervening dynamic scope.
RefPtr<RegisterID> base = generator.emitResolveBase(generator.newTemporary(), m_ident);
- RegisterID* value = generator.emitNode(m_init.get());
+ RegisterID* value = m_init ? generator.emitNode(m_init.get()) : generator.emitLoad(generator.newTemporary(), jsUndefined());
return generator.emitPutById(base.get(), m_ident, value);
}
+2008-08-05 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Darin.
+
+ Test for bug 20293: Crash in JavaScript codegen for eval("const a;")
+ <https://bugs.webkit.org/show_bug.cgi?id=20293>
+
+ * fast/js/const-expected.txt:
+ * fast/js/resources/const.js:
+
2008-08-05 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Oliver.
PASS inWith2 is 'RIGHT'
PASS (function(){ one = 2; return one; })() is 1
PASS f() is f
+PASS const a; is undefined
PASS successfullyParsed is true
TEST COMPLETE
var f = function g() { g="FAIL"; return g; };
shouldBe("f()", "f");
+shouldBe("const a;", "undefined");
+
var successfullyParsed = true;