-
Notifications
You must be signed in to change notification settings - Fork 119
Fix persistent func typing to compile motoko-core
#5484
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b524bd4
rename artifacts on draft release
Kamirus f65a429
try to link motoko-core to luc/oo-data-structures
Kamirus cc4fab2
allow digits
Kamirus 2a5e94e
repro type inference needs fixing
Kamirus 9ccfb8c
bug?
Kamirus e016f2f
claudio bimatch repro
Kamirus 1447d0f
missing error where assert was
Kamirus b309b93
claudio test with module in test/fail
Kamirus ad5b9d1
eop only test, running
Kamirus 4600bd3
rel_sort, combine_sort
Kamirus f3cd872
fix test
Kamirus 66b6b95
line change
Kamirus 2832156
try disabling implicit func conversion from Stable to Flexible when e…
Kamirus 64789bc
script for replacing mops-cached moc, with backups and restore
Kamirus 552f834
fix draft tag to match the version + suffix
Kamirus c4d9368
refactor
Kamirus 76c62d2
restore motoko-core branch
Kamirus 11340ce
tmp disable macos-13
Kamirus 62131d6
rel_func_sort ~eq and sub_func_sort
Kamirus 5028f5a
remove done todo
Kamirus b31e1a4
revert #5491, cleaunp
Kamirus 636b15a
damn you run.sh and your extra moc args...
Kamirus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| persistent-func-type-argument-and-return.mo:7.40-7.42: type error [M0220], this function should be declared `persistent` |
1 change: 1 addition & 0 deletions
1
test/fail/ok/persistent-func-type-argument-and-return.tc.ret.ok
This file contains hidden or 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 @@ | ||
| Return code 1 |
This file contains hidden or 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,8 @@ | ||
| module { | ||
| persistent func g<T>(x : T) : persistent() -> T { | ||
| persistent func h() : T { x }; | ||
| h; | ||
| }; | ||
| // don't allow `func() {}` to typecheck as `persistent() -> ()` for now | ||
| let h = g<persistent() -> ()>(func() {}); | ||
| }; | ||
2 changes: 2 additions & 0 deletions
2
test/run-drun/ok/persistent-actor-with-persistent-funcs-in-type-args-and-return.drun-run.ok
This file contains hidden or 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,2 @@ | ||
| ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 | ||
| ingress Completed: Reply: 0x4449444c0000 |
9 changes: 9 additions & 0 deletions
9
test/run-drun/persistent-actor-with-persistent-funcs-in-type-args-and-return.mo
This file contains hidden or 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,9 @@ | ||
| //ENHANCED-ORTHOGONAL-PERSISTENCE-ONLY | ||
| persistent actor { | ||
| persistent func g<T>(x : T) : persistent() -> T { | ||
| persistent func h() : T { x }; | ||
| h; | ||
| }; | ||
| let h = g<persistent() -> ()>(persistent func _anon() {}); | ||
| h(); | ||
| }; |
This file contains hidden or 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,23 @@ | ||
| type Order = { #less; #equal; #greater }; | ||
|
|
||
| module Array { | ||
| public func sort<T>(array : [T], compare : (T, T) -> Order) : [T] { | ||
| if (compare(array[0], array[1]) == #greater) { | ||
| [array[1], array[0]]; | ||
| } else { | ||
| array; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| module Nat { | ||
| public persistent func compare(x : Nat, y : Nat) : Order { | ||
| if (x < y) { #less } else if (x == y) { #equal } else { #greater }; | ||
| }; | ||
| }; | ||
|
|
||
| let a : [Nat] = [2, 1]; | ||
| let b : [Nat] = [1, 2]; | ||
|
|
||
| assert Array.sort(a, Nat.compare) == [1, 2]; | ||
| assert Array.sort(b, Nat.compare) == [1, 2]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I think anonymous lambdas can never be persistent in Luc's design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They need a name, I have it in another test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think even just a name ain't enough. The name needs to be unique in the path (i.e. a declaration in a persistent context).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this test is passing https://github.com/dfinity/motoko/pull/5484/files#diff-fcef2042739c68f514af2918041769a33351fe675b46e578e11c72d23c210b06R7
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the same issue as the
B.moor theC.mofile in here: https://github.com/dfinity/motoko/pull/5354/files#diff-0e9e9083aa4cfa901cd7251a640e3a9b3f95eb13e0b10b34ed5bfeaa6b20ab1c