gll icon indicating copy to clipboard operation
gll copied to clipboard

Redundant `X | X` rules are allowed and mismanaged.

Open eddyb opened this issue 6 years ago • 3 comments

This is a testcase that demonstrates the problem (in tests/basic.rs):

    multiple {
        A = X:"x" | Y:"x";
    }:
    A("x") => "\
1:1-1:2 => A::X(
    1:1-1:2,
)";

The output is the current one and is incorrect: both sides are "x" and should match or the situation should be statically denied. But only the first one is observed.

eddyb avatar Jul 20 '19 18:07 eddyb

I think a reasonable thing to do might be to use IndexSet instead of Vec in Or and make it an error to have duplicate rules (unless they have identical fields?).

eddyb avatar Jul 23 '19 03:07 eddyb

I also think it would be reasonable to prohibit identically matching rules in a single Or disjunction.

CAD97 avatar Jul 23 '19 15:07 CAD97

One problem with prohibiting identically matching rules is that it reduces to grammar equality, which is undecidable for basically anything with the complexity of CFG or higher.

eternaleye avatar Nov 11 '20 23:11 eternaleye