8000 result can't be used in expressions when not initialized · Issue #191 · gemoc/ale-lang · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
result can't be used in expressions when not initialized #191
Open
@echebbi

Description

@echebbi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0