diff --git a/src/alasqlparser.jison b/src/alasqlparser.jison index ec3c6973d1..6d5fdf39db 100755 --- a/src/alasqlparser.jison +++ b/src/alasqlparser.jison @@ -2960,12 +2960,11 @@ TermsList ; Term - : Literal - { $$ = new yy.Term({termid:$1}); } - | Literal LPAR TermsList RPAR - { $$ = new yy.Term({termid:$1,args:$3}); } - ; - + : Literal + { $$ = {termid: $1}; } + | Literal LPAR TermsList RPAR + { $$ = {termid:$1, args:$3}; } + ; Query : QUESTIONDASH FuncValue ; diff --git a/src/alasqlparser.js b/src/alasqlparser.js index 0c3d31d25f..efda93985d 100755 --- a/src/alasqlparser.js +++ b/src/alasqlparser.js @@ -1758,10 +1758,10 @@ case 759: this.$ = new yy.AddRule({right:$$[$0]}); break; case 762: - this.$ = new yy.Term({termid:$$[$0]}); + this.$ = {termid: $$[$0]}; break; case 763: - this.$ = new yy.Term({termid:$$[$0-3],args:$$[$0-1]}); + this.$ = {termid:$$[$0-3], args:$$[$0-1]}; break; case 766: diff --git a/test/test1871.js b/test/test1871.js new file mode 100644 index 0000000000..bad4d65b53 --- /dev/null +++ b/test/test1871.js @@ -0,0 +1,15 @@ +if (typeof exports === 'object') { + var assert = require('assert'); + var alasql = require('..'); +} + +describe('Test 1871 - n.Term is not a constructor', function () { + it('Sending xxx random data should give valid error', function () { + assert.throws( + () => alasql('xxx'), + { + message: "Parse error on line 1:\nxxx\n---^\nExpecting 'COLONDASH', got 'EOF'", + } + ); + }); +});