Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential (but highly unlikely) stack overflow #8

Open
rockymeza opened this issue Aug 2, 2019 · 0 comments
Open

Potential (but highly unlikely) stack overflow #8

rockymeza opened this issue Aug 2, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@rockymeza
Copy link
Contributor

If you have a super deeply nested expression, the Evaluator#resolve method is susceptible to stack overflows.

We could rewrite using a stack and a while loop to avoid this problem. (This may make it easier to build a stack trace for error messages too)

here's a failing test:

# The Evaluator#resolve method is susceptible to stack overflows.
# The test below uncovers that.
#
# it 'can evaluate nested expressions of arbitrary depth' do
# expression = ['add', 0, 1]
# 3843.times do
# expression = ['add', expression, 1]
# end
# expect(evaluator.resolve(expression)).to eq(3844)
# end

Notes:

@rockymeza rockymeza added the enhancement New feature or request label Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant