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

When solving an expression with dependencies, are cyclic errors always raised before unbound variable errors? #77

Closed
rcanand opened this issue Mar 15, 2016 · 1 comment

Comments

@rcanand
Copy link

rcanand commented Mar 15, 2016

Sorry for entering this as an issue - it is more of a clarification - I didn't find a contact link on the main page.

Is it guaranteed, that, given a hash of expressions without any stored values, solve! will always return cyclic errors before unbound variable errors? I checked and it seemed to work, but wanted to confirm, as that is critical to my scenario.

    calc = Dentaku::Calculator.new
    # case 1
    need_to_compute = {
      income_taxes: "annual_income / 5",
      annual_income: "monthly_income * 12"
    }

    # case 2
    calc.solve! need_to_compute #=> Unbound variable error

    need_to_compute = {
      income_taxes: "annual_income / 5",
      annual_income: "monthly_income * 12",
      monthly_income: 'annual_income'
    }

    calc.solve! need_to_compute #=> Cyclic error 
    # Is it always the case that cyclic error will be raised before 
    # unbound variable error in cases like case 2 above?
@rubysolo
Copy link
Owner

Yes, that's correct. Dependency resolution (which can raise Cyclic error) happens first, then evaluation (which can raise Unbound Variable) happens later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants