diff --git a/escodegen.js b/escodegen.js index 847fc370..8c14b4fd 100644 --- a/escodegen.js +++ b/escodegen.js @@ -2348,7 +2348,7 @@ return '/' + expr.regex.pattern + '/' + expr.regex.flags; } - if (expr.value === null) { + if (expr.value === null || (expr.raw === 'null' && expr.value === undefined)) { return 'null'; } diff --git a/test/verbatim.js b/test/verbatim.js index 0039fe34..24a3a61c 100644 --- a/test/verbatim.js +++ b/test/verbatim.js @@ -127,6 +127,12 @@ StringData = { object: { type: 'Literal', value: 0, verbatim: '0' }, property: { type: 'Identifier', name: 'a' }, computed: false + }, + // Null assignment + "foo = null": { + type: 'VariableDeclarator', + id: { type: 'Identifier', name: 'foo' }, + init: { type: 'Literal', raw: 'null' } } } };