Skip to content

Commit

Permalink
avoid nested bianry operator stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 28, 2020
1 parent 02f54dc commit 4520605
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 327 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

Now esbuild will go through the file system when transforming large files (currently >1mb). This approach is only faster for large files, and can be significantly slower for small files, so small files still keep everything in memory.

* Avoid stack overflow for binary operator chains

Syntax trees with millions of sequential binary operators nested inside each other can cause the parser to stack overflow because it uses a recursive visitor pattern, so each binary operator added an entry to the call stack. Now code like this no longer triggers a stack overflow because the visitor uses the heap instead of the stack in this case. This is unlikely to matter in real-world code but can show up in certain artificial test cases, especially when `--minify-syntax` is enabled.

## 0.6.8

* Attempt to support the taobao.org registry ([#291](https://github.com/evanw/esbuild/issues/291))
Expand Down
4 changes: 2 additions & 2 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ const (
BinOpLogicalAndAssign
)

type opTableEntry struct {
type OpTableEntry struct {
Text string
Level L
IsKeyword bool
}

var OpTable = []opTableEntry{
var OpTable = []OpTableEntry{
// Prefix
{"+", LPrefix, false},
{"-", LPrefix, false},
Expand Down
Loading

0 comments on commit 4520605

Please sign in to comment.