www.digitalmars.com         C & C++   DMDScript  

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