Commit 20f9be94 authored by oliver@apple.com's avatar oliver@apple.com

Fix Bug 17018: Incorrect code generated from Function.toString for get/setters in object literals

Reviewed by Darin.

Don't quote getter and setter names during output, as that is simply wrong.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e65bc9ac
2008-01-26 Oliver Hunt <oliver@apple.com>
Reviewed by Darin.
Fix Bug 17018: Incorrect code generated from Function.toString for get/setters in object literals
Don't quote getter and setter names during output, as that is simply wrong.
* kjs/nodes2string.cpp:
(KJS::PropertyNode::streamTo):
2008-01-26 Darin Adler <darin@apple.com>
Reviewed by Eric Seidel.
......
......@@ -380,11 +380,11 @@ void PropertyNode::streamTo(SourceStream& s) const
case Setter: {
const FuncExprNode* func = static_cast<const FuncExprNode*>(assign.get());
if (type == Getter)
s << "get \"";
s << "get ";
else
s << "set \"";
s << "set ";
s << escapeStringForPrettyPrinting(name().ustring())
<< "\"(" << func->param << ')' << func->body;
<< "(" << func->param << ')' << func->body;
break;
}
}
......
2008-01-26 Oliver Hunt <oliver@apple.com>
Reviewed by Darin.
Add test for getters and setters as part of fix for bug #17018
* fast/js/function-toString-object-literals-expected.txt:
* fast/js/resources/function-toString-object-literals.js:
2008-01-26 Darin Adler <darin@apple.com>
Reviewed by Oliver.
......
......@@ -17,6 +17,8 @@ PASS compileAndSerialize('a = { "1": null }') is 'a = { 1: null }'
PASS compileAndSerialize('a = { "1hi": null }') is 'a = { "1hi": null }'
PASS compileAndSerialize('a = { "\'": null }') is 'a = { "\'": null }'
PASS compileAndSerialize('a = { "\\"": null }') is 'a = { "\\"": null }'
PASS compileAndSerialize('a = { get x() { } }') is 'a = { get x() { } }'
PASS compileAndSerialize('a = { set x(y) { } }') is 'a = { set x(y) { } }'
PASS compileAndSerialize('a = { --1: null }') threw exception SyntaxError: Parse error.
PASS compileAndSerialize('a = { -NaN: null }') threw exception SyntaxError: Parse error.
PASS compileAndSerialize('a = { -0: null }') threw exception SyntaxError: Parse error.
......
......@@ -30,6 +30,9 @@ shouldBe("compileAndSerialize('a = { \"1hi\": null }')", "'a = { \"1hi\": null }
shouldBe("compileAndSerialize('a = { \"\\\'\": null }')", "'a = { \"\\\'\": null }'");
shouldBe("compileAndSerialize('a = { \"\\\\\"\": null }')", "'a = { \"\\\\\"\": null }'");
shouldBe("compileAndSerialize('a = { get x() { } }')", "'a = { get x() { } }'");
shouldBe("compileAndSerialize('a = { set x(y) { } }')", "'a = { set x(y) { } }'");
shouldThrow("compileAndSerialize('a = { --1: null }')");
shouldThrow("compileAndSerialize('a = { -NaN: null }')");
shouldThrow("compileAndSerialize('a = { -0: null }')");
......
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