From 4777a6b3605b5d6227ccc7d5349b52e0d91e53b3 Mon Sep 17 00:00:00 2001 From: Aman Rusia Date: Mon, 2 Jun 2025 12:14:11 +0530 Subject: [PATCH] Fix parsing of instantiation expressions with template literals Fixes #329 The issue was that template call expressions only allowed primary_expression or new_expression as the function, but instantiation expressions like `sql`template`` were not supported. This change adds $.instantiation_expression to the allowed function types for template calls, enabling proper parsing of patterns like: - sql`'[]'` - tag`Hello ${name}` - func`SELECT * FROM table` Testing shows this resolves the parsing inconsistency where removing certain lines would cause the entire file to fail parsing. --- common/define-grammar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/define-grammar.js b/common/define-grammar.js index efb0b76a..fd8fef34 100644 --- a/common/define-grammar.js +++ b/common/define-grammar.js @@ -177,7 +177,7 @@ module.exports = function defineGrammar(dialect) { field('arguments', $.arguments), )), prec('template_call', seq( - field('function', choice($.primary_expression, $.new_expression)), + field('function', choice($.primary_expression, $.new_expression, $.instantiation_expression)), field('arguments', $.template_string), )), prec('member', seq(