-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't generate
inj{S, S}
when symbol overloads have the same sort (#…
…4136) It is valid for two overloaded symbols to have the same sort; a motivating case for doing so is to select a _more specific function implementation_ based on more specific arguments, rather than to make the sort of a constructor more specific. We do this a few times in the C semantics, for example. Previously, such overloads would generate spurious injections `inj{S, S}` in the "overloaded symbol" axioms. Because we don't actually rewrite based on these axioms (but rather just read off the relevant attributes), this behaviour went unrecognised for a long time. For consistency, this PR amends ModuleToKore such that it will not generate the injection when the sort of the two productions is the same. We're in the process of porting this code to Python, and so I have not made any effort to clean up the code here; doing so is really outside the scope of this change. I have added a test that minimally exercises this part of the KORE generator, and verifies that the overload set induced works correctly to disambiguate a parse. Fixes: #4114
- Loading branch information
Showing
5 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
k-distribution/tests/regression-new/issue-4114-overload-injection/1.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test(foo) |
3 changes: 3 additions & 0 deletions
3
k-distribution/tests/regression-new/issue-4114-overload-injection/1.test.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<k> | ||
true ~> .K | ||
</k> |
7 changes: 7 additions & 0 deletions
7
k-distribution/tests/regression-new/issue-4114-overload-injection/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DEF=test | ||
EXT=test | ||
TESTDIR=. | ||
KOMPILE_BACKEND=llvm | ||
KOMPILE_FLAGS=--syntax-module TEST | ||
|
||
include ../../../include/kframework/ktest.mak |
12 changes: 12 additions & 0 deletions
12
k-distribution/tests/regression-new/issue-4114-overload-injection/test.k
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module TEST | ||
imports DOMAINS | ||
|
||
syntax Foo ::= "foo" | ||
syntax Bar ::= Foo | "bar" | ||
|
||
syntax Bool ::= test(Foo) [function, overload(test)] | ||
| test(Bar) [function, overload(test)] | ||
|
||
rule test(foo) => true | ||
rule test(_) => false | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters