Skip to content
This repository was archived by the owner on Jun 26, 2022. It is now read-only.

Conversation

@jmsfltchr
Copy link
Contributor

@jmsfltchr jmsfltchr commented Mar 28, 2022

What is the goal of this PR?

Users could quite sensibly think that they can assign a type to a variable attribute in a rule then. This is not permitted because the type of a variable in the rule then has already been determined by the rule when. Users should be clearly told what the exact issue is and how to remedy this.

What are the changes implemented in this PR?

Tell the use the exact type and variable causing the issue and suggest to them to remove the type.
For example:

rule people-are-the-same:
when {
      $p isa person, has name $n;
    } then {
      $p has name $n;
    };

throws error:

[TQL31] TypeQL Error: Rule 'people-are-the-same' 'then' '$p has name $n' tries to assign type 'name' to variable 'n', but this variable already had a type assigned by the rule 'when'. Try omitting this type assignment.

@jmsfltchr
Copy link
Contributor Author

Ideally variable 'n' should be variable '$n' - can we do this?

Comment on lines 137 to 138
String attr_var = then.has().get(0).attribute().name();
String attr_type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the python-style variable naming??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only because I wrote some Python recently 🤣 fixed now

@flyingsilverfin
Copy link
Member

don't forget to change the status to "in review" when it's ready to review, and also assign me as reviewer: both are required for it to turn up on my github board! I do tend to use this a lot when im only online sporadically as a quick summary of what's on my plate :)

@jmsfltchr jmsfltchr merged commit 775facb into typedb:master Apr 8, 2022
@jmsfltchr jmsfltchr deleted the improve-invalid-rule-then-has branch April 8, 2022 10:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants