-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Example code to reproduce the issue:
const comments = []
const source = [
"Promise.all([import('foo')])",
'// Some comment'
].join('\n')
const ast = acorn.parse(source, {
onComment: comments,
sourceType: 'module',
locations: true,
ecmaVersion: 2023
})
astravel.attachComments(ast, comments)You can see a demo on the astring demo site (be sure to check the Include comments checkbox). It produces the following stack trace:
TypeError: traveler2[child.type] is not a function
TypeError: traveler2[child.type] is not a function
at attachCommentsToNode (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:456:26)
at Object.ArrayExpression (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:481:5)
at Object.go (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:12:22)
at Object.CallExpression (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:271:12)
at Object.go (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:12:22)
at Object.ExpressionStatement (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:58:10)
at attachCommentsToNode (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:456:26)
at Object.Block$1 (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:471:3)
at Module.attachComments (https://cdn.skypack.dev/-/astravel@v0.6.1-J7Ht2wGP9zrf7okX2giu/dist=es2019,mode=imports/optimized/astravel.js:491:22)
at HTMLTextAreaElement.update (https://david.bonnet.cc/astring/demo/:78:22)
Seems to be specific to a Promise.all expression that includes an ImportExpression, e.g., Promise.all([import('foo')]). Any comment type following that will produce the error.
EDIT: The error can be triggered with this simplified source
[import('foo')]
// Some commentPotentially related to davidbonnet/astring#562.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels