Skip to content

Commit

Permalink
Bugfix import Expression, needs a Parameter for filename
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Apr 12, 2021
1 parent 3d910f3 commit 272dd32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Esprima/Ast/Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
{
public sealed class Import : Expression
{
public Import() : base(Nodes.Import)
public readonly Expression Source;

public Import(Expression source) : base(Nodes.Import)
{
Source = source;
}

public override NodeCollection ChildNodes => NodeCollection.Empty;
public override NodeCollection ChildNodes => new NodeCollection(Source);
}
}
17 changes: 16 additions & 1 deletion src/Esprima/JavascriptParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,22 @@ private Import ParseImportCall()
{
var node = CreateNode();
ExpectKeyword("import");
return this.Finalize(node, new Import());
Expect("(");
var source = ParseExpression();

if (!Match(")") && _config.Tolerant)
{
TolerateUnexpectedToken(NextToken());
}
else
{
Expect(")");
if (Match(";"))
{
NextToken();
}
}
return this.Finalize(node, new Import(source));
}

private Expression ParseLeftHandSideExpressionAllowCall()
Expand Down

0 comments on commit 272dd32

Please sign in to comment.