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

Using 'and' inside 'not' in a Rule Condition causes a build error #10

Open
olivvysaur opened this issue Feb 7, 2017 · 2 comments
Open

Using 'and' inside 'not' in a Rule Condition causes a build error #10

olivvysaur opened this issue Feb 7, 2017 · 2 comments
Labels
bug

Comments

@olivvysaur
Copy link

@olivvysaur olivvysaur commented Feb 7, 2017

If you write a rule with a condition which nests an and statement inside a not statement, the C program generated by gp2compile will fail to build.

An example of this is the condition

not ( edge(n0, n1) and edge(n1, n0) )

which validates successfully when using gp2compile -r … but the generated C code will fail to build with the following errors:

Main_r2.c:54:10: error: use of undeclared identifier 'b2'
         b2 = true;
         ^
Main_r2.c:59:20: error: use of undeclared identifier 'b2'
   if(!edge_found) b2 = false;
                   ^
Main_r2.c:109:13: error: use of undeclared identifier 'b2'
            b2 = false;
            ^
Main_r2.c:203:10: error: use of undeclared identifier 'b2'
         b2 = false;
         ^
4 errors generated.
make: *** [Main_r2.o] Error 1

Looking at Main_r2.c, the GP2 compiler has not generated the declaration for the boolean variable b2 at the top of the file.

@ivaylohristakiev

This comment has been minimized.

Copy link

@ivaylohristakiev ivaylohristakiev commented Feb 8, 2017

There seems to be a problem with evaluating nested conditions as well, apart from the above generation problem.

For example, if a program properly fails because a rule condition c is false, then rewriting the program with the same rule but condition not (not c) doesn't fail.

@GrahamCampbell

This comment has been minimized.

Copy link
Contributor

@GrahamCampbell GrahamCampbell commented Jan 16, 2019

The error I get when I try this is mildly different.

Main = foo

foo(a: int)
[ (n0, a) (n1, a) | ] => [ (n0, a) (n1, a) | ]
interface = {n0, n1}
where not ( edge(n0, n1) and edge(n1, n0) )

Results in:

Main_foo.c: In function 'evaluatePredicate1':
Main_foo.c:54:10: error: 'b1' undeclared (first use in this function); did you mean 'n1'?
          b1 = true;
          ^~
          n1
Main_foo.c:54:10: note: each undeclared identifier is reported only once for each function it appears in
Main_foo.c: In function 'match_n0':
Main_foo.c:122:13: error: 'b1' undeclared (first use in this function); did you mean 'b0'?
             b1 = false;
             ^~
             b0
Main_foo.c: In function 'match_n1':
Main_foo.c:183:13: error: 'b1' undeclared (first use in this function); did you mean 'b0'?
             b1 = false;
             ^~
             b0
make: *** [Main_foo.o] Error 1
make: *** Waiting for unfinished jobs....

@GrahamCampbell GrahamCampbell added the bug label Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.