|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
DMDScript - Object contructors and assign from Function calls bugs
I was just testing DMD script with extjs (www.extjs.org).
Two bugs came up:
var a = {
"=" : "a test",
123 : "a test"
}
= Support for raw strings and reals as object key values.
Fixing this is quite simple : inside parser.d / parseObjectLiteral
replace
if (token.value != TOKidentifier)
{ error(ERR_EXPECTED_IDENTIFIER);
break;
}
with something like:
switch (token.value) {
case TOKidentifier:
ident = token.ident;
break;
case TOKstring:
indent = Identifier.build(token.string);
break;
case TOKreal:
indent = Identifier.build(
std.string.toString(token.string));
break;
default:
break;
}
if (!ident) {
error(ERR_EXPECTED_IDENTIFIER);
break;
}
The other bug is that this syntax causes runtime errors.
var a = (function() { return { a: "test" } })();
- basically building an object based on the return value of an anonymous
function. (tends to be used to do private static variables in javascript)
I gave up trying to work out how to fix that one...
Regards
Alan
Apr 27 2007
|