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

A statement is executed even if one of its sub-expression produces an error #126

Closed
echebbi opened this issue May 5, 2020 · 0 comments · Fixed by #137
Closed

A statement is executed even if one of its sub-expression produces an error #126

echebbi opened this issue May 5, 2020 · 0 comments · Fixed by #137

Comments

@echebbi
Copy link
Collaborator

echebbi commented May 5, 2020

Expected behavior

A statement is not executed if one of its sub-expression is invalid.

Current behavior

The statement is executed, eventually leading to unexpected results / subtle errors.

Reproducible example

Given:

open class State {

    @main
    def void run() {
        self.transiton.log();
    }

}

When: the transition attribute does not exist (typo)

Then: the interpreter still calls the log() service, leading the exception to be printed twice:

image

Why does it happen?

log() is called on the result of self.transiton which is... the no attribute called transiton error itself! The issue seems to come from the NotifyingEvaluationServices which, in case of error, returns a "placeholder" holding the exception:

} catch (AcceleoQueryEvaluationException e) {
Nothing placeHolder = new Nothing(e.getMessage(), e);
if (e.getCause() instanceof AcceleoQueryEvaluationException) {
addDiagnosticFor(diagnostic, Diagnostic.WARNING, placeHolder);
} else {
addDiagnosticFor(diagnostic, Diagnostic.ERROR, placeHolder);
}
return placeHolder;
}

I tried to broadcast the exception instead but that resulted in the exception never being caught and crashing the whole interpreter. We have to be a bit more subtle here.

echebbi added a commit that referenced this issue May 5, 2020
…s right operand (#126)

Because:
 - an exception was thrown at runtime when concatenating two collections because the interpreter
   was excepting a scalar (fix #120)

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>

concatenate collections with static attributes

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>

az
echebbi added a commit that referenced this issue May 14, 2020
 #126)

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
@echebbi echebbi self-assigned this May 14, 2020
echebbi added a commit that referenced this issue Jun 4, 2020
 #126)

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
echebbi added a commit that referenced this issue Jun 4, 2020
 #126)

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant