Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Possible regression in 1.3.1: recursive variable definition produces incorrect output #23

Closed
hugsy opened this issue Jan 19, 2020 · 0 comments · Fixed by #28
Closed

Comments

@hugsy
Copy link

hugsy commented Jan 19, 2020

Hi,

First off, thank you for this awesome project.

I've recently updated to dharma 1.3.1 for my fuzzing projects, and noticed that it couldn't generate correct code anymore. After investigation it turned out that recursive definition of variable now produces an incorrect output.

Here is a basic test case for reproduction:

  • Grammar dharma_regression.dg
%section% := value

UseOfVar :=
    print(!var!);


%section% := variable

var :=
    @var@ = new Foo();
    @var@ = new FooFromVar(!var!);


%section% := variance

main :=
    +UseOfVar+

On dharma 1.2, the !var! used in the second variable definition is correctly recursed over until no dependencies are needed, which produces a "correct" output such as:

$ dharma -grammars dharma_regression.dg
var1 = new Foo();
var2 = new FooFromVar(var1);
var3 = new FooFromVar(var2);
var4 = new FooFromVar(var3);

print(var3);
print(var4);
print(var4);
print(var1);
print(var3);
print(var1);

However, by upgrading dharma 1.3.1, the test cases generated look more like:

$ dharma -grammars dharma_regression.dg
var2 = new FooFromVar(var2);
var2 = new FooFromVar(var2);
var3 = new Foo();

print(var2);
print(var3);

Which will produce "used-before-assigned" type of errors once trying to be executed. After some quick check, it seems that the regression was introduced by 834203f. With that commit reverted, the variable recursion operates as expected.

Can you confirm this behavior?

Thank you.

jschwartzentruber added a commit that referenced this issue Jun 12, 2020
This allows us to undo the change in 834203f
which causes incorrect output (fixes #23)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant