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

result can't be used in expressions when not initialized #191

Open
echebbi opened this issue Jul 17, 2020 · 0 comments
Open

result can't be used in expressions when not initialized #191

echebbi opened this issue Jul 17, 2020 · 0 comments

Comments

@echebbi
Copy link
Collaborator

echebbi commented Jul 17, 2020

Bug description

Using result in an expression leads to a runtime error during interpretation. For example, the following code produces an error during the evaluation of the if's condition:

class A {

    def boolean isX() {
        if (result) {
           
        }
        result := false;
    }

}

The error is "Couldn't find the 'result' variable".

Expected behavior

Not sure. One of the following:

  • result is set a default value,
  • it is explicitely forbidden to use result without initializing it first and this is enforced by an error marker in the editor.

How to reproduce

Steps to reproduce the behavior:

  1. Create an ALE project
  2. Write a semantics that uses result in an expression as shown above
  3. Run the interpreter

Additional context

Issue caused by the following line:

result = aqlEngine.eval(dummyAstResult, scopes.getCurrent().getVariableValues());

Since result has not been initialized yet, the map returned by scopes.getCurrent().getVariableValues() won't contain it. The appropriate fix depends on the chosen solution.

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

No branches or pull requests

1 participant