Skip to content

[Bug]: template.ast goes endless loop #15525

@await-ovo

Description

@await-ovo

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const template = require("@babel/template").default;

const name = 'a'
const ast = template.ast`
export  { ${name} }   
`
console.log(ast);

Configuration file name

No response

Configuration

No

Current and expected behavior

Should get ast as expected

Environment

System:
OS: macOS 11.7.4
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/Library/pnpm/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
npmPackages:
@babel/core: ^7.21.3 => 7.21.3
@babel/generator: ^7.21.3 => 7.21.3
@babel/parser: ^7.21.3 => 7.21.3
@babel/template: ^7.20.7 => 7.20.7

Possible solution

No

Additional context

It seems that no matter how many times it is executed, there will be a case where placeholder.isDuplicated be true, so it just keep looping here:

image

I am not sure if there is something wrong with my usage, if so, please tell me, thanks a lot!

Metadata

Metadata

Assignees

Labels

outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: template

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions