Skip to content

err:identifier n has already been declared  #69

@fzxs8

Description

@fzxs8

使用 下面的代码执行获取AST会出现错误.

golang 代码:

	ast, err := js.Parse(parse.NewInputBytes(jsStr))

JavaScript代码

const n = 100


let fi = [1, 2, 3, 4], r = []
for (let t = 0, n = fi.length; t < n; t++) {
    const n = fi[t];
    r.push(`${n}:${n + 1};`)
}
// if (n > 0) {
//     const n = 200;
//     r.push(`${n}:${n + 1};`)
// }
console.info(r)

出现了错误

err:identifier n has already been declared on line 6 and column 11
6: const n = fi[t];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions