You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was experimenting with globalizejs/globalize#720 when I found this.
If runtimeArgs contains undefined, the compiler will generate invalid code. E.g.:
var Globalize = require( "globalize" );
var globalizeCompiler = require('globalize-compiler');
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en" ) );
var GyMMMd = Globalize( "en" ).dateFormatter({ skeleton: "GyMMMd" });
GyMMMd.runtimeArgs.push(undefined);
GyMMMd.runtimeArgs.push(undefined);
var out = globalizeCompiler.compile([
GyMMMd,
], {});
The generated code will look like this:
Globalize.b938155015 = dateFormatterFn({"1":Globalize("en").numberFormatter({"raw":"0"})}, {"pattern":"MMM d, y G","timeSeparator":":","months":{"M":{"3":{"1":"Jan","2":"Feb","3":"Mar","4":"Apr","5":"May","6":"Jun","7":"Jul","8":"Aug","9":"Sep","10":"Oct","11":"Nov","12":"Dec"}}},"eras":{"0":"BC","1":"AD","0-alt-variant":"BCE","1-alt-variant":"CE"}}, , );
I was experimenting with globalizejs/globalize#720 when I found this.
If runtimeArgs contains undefined, the compiler will generate invalid code. E.g.:
The generated code will look like this:
The
, , );
is a syntax error.The replacement happens here: https://github.com/globalizejs/globalize-compiler/blob/v1.0.0/lib/compile.js#L142
I suspect this isn't likely to come up in real-world usage, but shouldn't the compiler generate undefined? i.e.:
The text was updated successfully, but these errors were encountered: