Skip to content

Commit

Permalink
Extend context with tagged template for property access
Browse files Browse the repository at this point in the history
  • Loading branch information
ypapouski committed Apr 3, 2024
1 parent 94c3066 commit b4617e2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/meriyah.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6314,7 +6314,7 @@
case 67108877: {
nextToken(parser, (context | 1073741824 | 8192) ^ 8192);
parser.assignable = 1;
const property = parsePropertyOrPrivatePropertyName(parser, context);
const property = parsePropertyOrPrivatePropertyName(parser, context | 65536);
expr = finishNode(parser, context, start, line, column, {
type: 'MemberExpression',
object: expr,
Expand Down
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4043,7 +4043,7 @@ export function parseMemberOrUpdateExpression(

parser.assignable = AssignmentKind.Assignable;

const property = parsePropertyOrPrivatePropertyName(parser, context);
const property = parsePropertyOrPrivatePropertyName(parser, context | Context.TaggedTemplate);

expr = finishNode(parser, context, start, line, column, {
type: 'MemberExpression',
Expand Down
45 changes: 44 additions & 1 deletion test/parser/expressions/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ describe('Expressions - Template', () => {
"(function tag() { return () => {}; })()`'\\00a0'`",
"(function() { return () => {}; })()`'\\00a0'`",
"(function tag() {})`'\\00a0'`",
"(function() {})`'\\00a0'`"
"(function() {})`'\\00a0'`",
'String.raw`{\rtf1adeflang1025ansiansicpg1252\\uc1`;'
]) {
it(`${arg}`, () => {
t.doesNotThrow(() => {
Expand Down Expand Up @@ -4126,6 +4127,48 @@ describe('Expressions - Template', () => {
sourceType: 'script',
type: 'Program'
}
],
[
'String.raw`{\rtf1adeflang1025ansiansicpg1252\\uc1`;',
Context.None,
{
body: [
{
expression: {
quasi: {
expressions: [],
quasis: [
{
tail: true,
type: 'TemplateElement',
value: {
cooked: undefined,
raw: '{\rtf1adeflang1025ansiansicpg1252\\uc1'
}
}
],
type: 'TemplateLiteral'
},
tag: {
computed: false,
object: {
name: 'String',
type: 'Identifier'
},
property: {
name: 'raw',
type: 'Identifier'
},
type: 'MemberExpression'
},
type: 'TaggedTemplateExpression'
},
type: 'ExpressionStatement'
}
],
sourceType: 'script',
type: 'Program'
}
]
]);
});

0 comments on commit b4617e2

Please sign in to comment.