-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic typechecking for helper functions (#248)
* feat: func typechecks added * Error message updated and deprimify prototype * first attempt at DFS * feat: added deprimify * change deprimify to use values --------- Co-authored-by: k-mouline <karim_mouline@brown.edu>
- Loading branch information
Showing
12 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
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
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
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[b: B, a: A] : lone B { | ||
a.f1 | ||
} | ||
|
||
test expect { | ||
should_error: {some b1, b2: B | f[b1, b2] = b2} is sat | ||
} |
12 changes: 12 additions & 0 deletions
12
forge/tests/error/mismatched-arg-type-fun-codomain-int.frg
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[a: A] : Int { | ||
a.f1 | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
12 changes: 12 additions & 0 deletions
12
forge/tests/error/mismatched-arg-type-fun-codomain-non-primsig.frg
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
one sig B { f2: lone A } | ||
|
||
fun f[a: A] : B { | ||
a | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[a: A] : lone B { | ||
a | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[a: A] : lone A { | ||
3 | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
12 changes: 12 additions & 0 deletions
12
forge/tests/error/mismatched-arg-type-fun-output-non-primsig.frg
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
one sig B { f2: lone A } | ||
|
||
fun f[a: A] : lone A { | ||
B | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[a: A] : lone A { | ||
a.f1 | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} |
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { } | ||
|
||
fun f[a: A] : lone A { | ||
univ | ||
} | ||
|
||
test expect { | ||
should_error: {some a: A | f[a] = a} is sat | ||
} | ||
|
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 @@ | ||
#lang forge/bsl | ||
|
||
sig A { f1: lone B } | ||
sig B { f2: lone A } | ||
|
||
fun f[a: A] : lone B { | ||
a.f1 | ||
} | ||
|
||
test expect { | ||
should_error: {some b: B | f[b] = b} is sat | ||
} |
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,16 @@ | ||
#lang forge | ||
|
||
sig A{ } | ||
sig A_child1 extends A { } | ||
sig A_child2 extends A {} | ||
sig B { } | ||
sig B_child1 extends B { } | ||
sig B_child2 extends B { } | ||
sig B_child1_child extends B_child1 { } | ||
pred p[a: B_child1 + A] { | ||
} | ||
|
||
|
||
test expect { | ||
practicing: {some x: B_child2 | p[x]} is sat | ||
} |