Skip to content

Bug with nested curly braces in template strings #1538

Description

@TwitchBronBron

There's a bug with the lexer or parser for nested curly braces in template strings. Here's a test that is currently failing, but should pass.

it.only('handles nested curly braces', () => {
            let tokens = Lexer.scan('thing = `${{}}`').tokens;
            expect(tokens.map(x => x.kind)).to.eql([
                TokenKind.Identifier,
                TokenKind.Equal,
                TokenKind.BackTick,
                TokenKind.TemplateStringQuasi,
                TokenKind.TemplateStringExpressionBegin,
                TokenKind.LeftCurlyBrace,
                TokenKind.RightCurlyBrace,
                TokenKind.TemplateStringExpressionEnd,
                TokenKind.TemplateStringQuasi,
                TokenKind.BackTick,
                TokenKind.Eof
            ]);
        });

Requirements:

  • fix the lexer or parser to ensure that this syntax is supported
  • ensure the existing unit tests all pass without needing to modify them, since that would be backwards breaking changes
  • write new unit tests to ensure this behavior doesn't break again in the future.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions