Skip to content

Commit

Permalink
Merge pull request #4326 from unisonweb/fix/mcode-dependencies
Browse files Browse the repository at this point in the history
Add missing dependency crawling for MCode
  • Loading branch information
pchiusano authored Sep 20, 2023
2 parents 538c742 + cbd9128 commit f761c09
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
8 changes: 8 additions & 0 deletions parser-typechecker/src/Unison/Runtime/MCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,10 @@ sectionDeps :: Section -> [Word64]
sectionDeps (App _ (Env w _) _) = [w]
sectionDeps (Call _ w _) = [w]
sectionDeps (Match _ br) = branchDeps br
sectionDeps (DMatch _ _ br) = branchDeps br
sectionDeps (RMatch _ pu br) =
sectionDeps pu ++ foldMap branchDeps br
sectionDeps (NMatch _ _ br) = branchDeps br
sectionDeps (Ins i s)
| Name (Env w _) _ <- i = w : sectionDeps s
| otherwise = sectionDeps s
Expand All @@ -1451,6 +1455,10 @@ sectionTypes :: Section -> [Word64]
sectionTypes (Ins i s) = instrTypes i ++ sectionTypes s
sectionTypes (Let s _) = sectionTypes s
sectionTypes (Match _ br) = branchTypes br
sectionTypes (DMatch _ _ br) = branchTypes br
sectionTypes (NMatch _ _ br) = branchTypes br
sectionTypes (RMatch _ pu br) =
sectionTypes pu ++ foldMap branchTypes br
sectionTypes _ = []

instrTypes :: Instr -> [Word64]
Expand Down
22 changes: 21 additions & 1 deletion unison-cli/integration-tests/IntegrationTests/transcript.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,28 @@
```unison
use .builtin
unique type MyBool = MyTrue | MyFalse
structural ability Break where
break : ()
resume = cases
{ x } -> id x
{ break -> k } ->
void 5
handle k () with resume
main : '{IO, Exception} ()
main = '(printLine "Hello, world!")
main = do
match MyTrue with
MyTrue -> match 0 with
0 ->
handle
break
printLine "Hello, world!"
with resume
_ -> ()
_ -> ()
```

```ucm
Expand Down
32 changes: 29 additions & 3 deletions unison-cli/integration-tests/IntegrationTests/transcript.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
```unison
use .builtin
unique type MyBool = MyTrue | MyFalse
structural ability Break where
break : ()
resume = cases
{ x } -> id x
{ break -> k } ->
void 5
handle k () with resume
main : '{IO, Exception} ()
main = '(printLine "Hello, world!")
main = do
match MyTrue with
MyTrue -> match 0 with
0 ->
handle
break
printLine "Hello, world!"
with resume
_ -> ()
_ -> ()
```

```ucm
Expand All @@ -15,15 +35,21 @@ main = '(printLine "Hello, world!")
⍟ These new definitions are ok to `add`:
main : '{IO, Exception} ()
structural ability Break
unique type MyBool
main : '{IO, Exception} ()
resume : Request {g, Break} x -> x
```
```ucm
.> add
⍟ I've added these definitions:
main : '{IO, Exception} ()
structural ability Break
unique type MyBool
main : '{IO, Exception} ()
resume : Request {g, Break} x -> x
.> compile main ./unison-cli/integration-tests/IntegrationTests/main
Expand Down

0 comments on commit f761c09

Please sign in to comment.