-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect termination for nested local definitions (#3169)
* Closes #3147 When we call a function that is currently being defined (there may be several such due to nested local definitions), we add a reflexive edge in the call map instead of adding an edge from the most nested definition. For example, for ```juvix go {A B} (f : A -> B) : List A -> List B | nil := nil | (elem :: next) := let var1 := f elem; var2 := go f next; in var1 :: var2; ``` we add an edge from `go` to the recursive call `go f next`, instead of adding an edge from `var2` to `go f next` as before. This makes the above type-check. The following still doesn't type-check, because `next'` is not a subpattern of the clause pattern of `go`. But this is a less pressing problem. ```juvix go {A B} (f : A -> B) : List A -> List B | nil := nil | (elem :: next) := let var1 := f elem; var2 (next' : List A) : List B := go f next'; in myCons var1 (var2 next); ```
- Loading branch information
Showing
6 changed files
with
110 additions
and
24 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
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,11 @@ | ||
module Nested1; | ||
|
||
import Stdlib.Data.List open; | ||
|
||
go {A B} (f : A -> B) : List A -> List B | ||
| nil := nil | ||
| (elem :: next) := | ||
let | ||
var1 := f elem; | ||
var2 := go f next; | ||
in var1 :: var2; |
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 @@ | ||
module Nested2; | ||
|
||
type MyList A := | ||
| myNil | ||
| myCons@{ | ||
elem : A; | ||
next : MyList A; | ||
}; | ||
|
||
go {A B} (f : A -> B) : MyList A -> MyList B | ||
| myNil := myNil | ||
| myCons@{elem; next} := | ||
myCons@{ | ||
elem := f elem; | ||
next := go f next; | ||
}; |