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

fix: Make datatype cycle detection independent of auto-init #4997

Merged
merged 24 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5d45706
chore: Add documentation and sanity assertions
RustanLeino Jan 18, 2024
c868719
Compute IsObviouslyEmpty for inductive datatypes
RustanLeino Jan 18, 2024
d205272
Fix typo in comment
RustanLeino Jan 19, 2024
4036d59
Don’t use cache (that conflates all type-parrameter instantiations)
RustanLeino Jan 19, 2024
013546b
Also check cycles going through result type of total arrows
RustanLeino Jan 19, 2024
6fea52f
Add tests, and adjust for ordering for checks
RustanLeino Jan 19, 2024
a1f78c5
Simplify tests
RustanLeino Jan 19, 2024
bc9354b
Rename test file
RustanLeino Jan 19, 2024
98a3240
Add verification tests to confirm not auto-init
RustanLeino Jan 19, 2024
d6343ed
Set grounding-ctor-type-parameters and test compilation
RustanLeino Jan 19, 2024
8079558
Fix typo in comment
RustanLeino Jan 19, 2024
2fe447a
Merge branch 'master' into issue-4939
RustanLeino Jan 19, 2024
77f6046
Add release notes
RustanLeino Jan 19, 2024
2018422
Merge branch 'master' into issue-4939
RustanLeino Jan 19, 2024
5d1aec4
Merge branch 'master' into issue-4939
RustanLeino Jan 19, 2024
aec8edc
Fix whitespace
RustanLeino Jan 19, 2024
e660898
Don’t bother with cyclicity test if datatype had refinement error dur…
RustanLeino Jan 19, 2024
0cbc0dd
Change no-instance-because-of-datatype-cycle error into warning
RustanLeino Jan 22, 2024
a1275b1
Add a test that shows an empty datatype is provably empty
RustanLeino Jan 22, 2024
fc44f01
chore: Improve C#
RustanLeino Jan 23, 2024
2a660b5
fix: Box function-body results and let-RHS from datatype to trait
RustanLeino Jan 23, 2024
53ee5a4
Merge branch 'master' into issue-4939
RustanLeino Jan 23, 2024
84a81d5
Merge branch 'master' into issue-4939
ssomayyajula Jan 23, 2024
aad6805
Merge branch 'master' into issue-4939
RustanLeino Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests, and adjust for ordering for checks
  • Loading branch information
RustanLeino committed Jan 19, 2024
commit 6fea52f16d959f128372e0231af8d9c81e24ea8a
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class C {

datatype D = A

datatype NeverendingList = Cons(int, NeverendingList) // error: no grounding constructor


datatype MutuallyRecursiveDataType<T> =
FromANumber(int) | // this is the base case
Expand Down Expand Up @@ -246,7 +246,36 @@ module OtherCycles1 {
}

module OtherCycles2 {
datatype CycleW = CycleW(CycW)
// the next line uses a general arrow
datatype CycleW = CycleW(int ~> CycW)
type CycW = c: CycleW | true witness W() // error: dependency cycle W -> CycW -> CycleW
function W(): CycleW
}

module OtherCycles3 {
// the next line uses a partial arrow
datatype CycleW = CycleW(int -> CycW) // error: dependency cycle W -> CycW -> CycleW
type CycW = c: CycleW | true witness W()
function W(): CycleW
}

module OtherCycles4 {
// the next line uses a total arrow
datatype CycleW = CycleW(int -> CycW) // error: because of cycle among constructor argument types, 'CycleW' is empty
type CycW = c: CycleW | true witness W()
function W(): CycleW
}

module OtherCycles5 {
// the next line uses a subset type over a total arrow
type MyTotalArrow<X, Y> = f: X -> Y | true
datatype CycleW = CycleW(MyTotalArrow<int, CycW>) // error: because of cycle among constructor argument types, 'CycleW' is empty
type CycW = c: CycleW | true witness W()
function W(): CycleW
}

module NE {
datatype NeverendingList = Cons(int, NeverendingList) // error: empty type
datatype Growing<X> = Make(Growing<array<X>>) // error: empty type
datatype MaybeGrowing<X> = Make(array<MaybeGrowing<X>>) // okay, since it does not violate the cycle rule
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ TypeTests.dfy(10,14): Error: incorrect argument type at index 1 for function par
TypeTests.dfy(16,16): Error: incorrect argument type for method in-parameter 'x' (expected int, found bool)
TypeTests.dfy(16,16): Error: incorrect return type at index 1 for method out-parameter 'c' (expected C, got int)
TypeTests.dfy(17,12): Error: incorrect return type at index 1 for method out-parameter 'c' (expected C, got int)
TypeTests.dfy(23,9): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'NeverendingList' can be constructed
TypeTests.dfy(169,7): Error: non-ghost variable cannot be assigned a value that depends on a ghost
TypeTests.dfy(179,6): Error: cannot assign to non-ghost variable in a ghost context
TypeTests.dfy(180,9): Error: cannot assign to non-ghost variable in a ghost context
Expand All @@ -38,5 +37,10 @@ TypeTests.dfy(238,20): Error: using the type being defined ('B') here would caus
TypeTests.dfy(243,20): Error: using the type being defined ('E') here would cause a logical inconsistency by defining a type whose cardinality exceeds itself (like the Continuum Transfunctioner, you might say its power would then be exceeded only by its mystery)
TypeTests.dfy(244,20): Error: using the type being defined ('F') here would cause a logical inconsistency by defining a type whose cardinality exceeds itself (like the Continuum Transfunctioner, you might say its power would then be exceeded only by its mystery)
TypeTests.dfy(245,20): Error: using the type being defined ('G') here would cause a logical inconsistency by defining a type whose cardinality exceeds itself (like the Continuum Transfunctioner, you might say its power would then be exceeded only by its mystery)
TypeTests.dfy(250,7): Error: recursive constraint dependency involving a subset type: CycW -> W -> CycleW -> CycW
41 resolution/type errors detected in TypeTests.dfy
TypeTests.dfy(251,7): Error: recursive constraint dependency involving a subset type: CycW -> W -> CycleW -> CycW
TypeTests.dfy(257,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'CycleW' can be constructed
TypeTests.dfy(264,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'CycleW' can be constructed
TypeTests.dfy(272,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'CycleW' can be constructed
TypeTests.dfy(278,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'NeverendingList' can be constructed
TypeTests.dfy(279,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'Growing' can be constructed
45 resolution/type errors detected in TypeTests.dfy
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
// RUN: %exits-with 2 %verify "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

datatype T = T(T, T) {
ghost predicate P() {
match this
case T(0, 1) => false
module A {
datatype T = T(T, T)
{
ghost predicate P() {
match this
case T(0, 1) => false // error (x2): neither constant pattern of constructor pattern has the right type
}
}
}
method a()
{
var tok := (0,0);

method M() {
var tok := (0, 0);
match tok {
case "B" =>
case "B" => // error: "B" is not of type (int, int)
case _ =>
}
}
}

module B {
datatype T = T(T, T) // error (masked by other errors in module A): cycle prevents instances
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git-issue-2139.dfy(14,11): Error: pattern doesn't correspond to a tuple
git-issue-2139.dfy(7,13): Error: Constant pattern used in place of datatype
git-issue-2139.dfy(7,16): Error: Constant pattern used in place of datatype
git-issue-2139.dfy(4,9): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'T' can be constructed
git-issue-2139.dfy(16,11): Error: pattern doesn't correspond to a tuple
git-issue-2139.dfy(9,13): Error: Constant pattern used in place of datatype
git-issue-2139.dfy(9,16): Error: Constant pattern used in place of datatype
git-issue-2139.dfy(23,11): Error: because of cyclic dependencies among constructor argument types, no instances of datatype 'T' can be constructed
4 resolution/type errors detected in git-issue-2139.dfy