-
Notifications
You must be signed in to change notification settings - Fork 116
feat: generalized imports supporting pattern matching and selective field import #3076
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
Changes from 7 commits
b46e72a
e6e9915
67500bf
2d40582
1556274
3b120ee
bcf3fcb
59efd68
957f912
a1ee29c
91c3708
8d7fb3c
8fe6866
ddcef0f
f581947
0eff5af
999d654
c32448f
58c629c
ad314b7
2e9df25
7293902
93dcc88
1a0a069
e72ce22
d43c7ab
3669465
6efb5f6
b109d6d
4c94e00
1eef8dc
e3ee5f1
968cadc
9c911ca
2c3f4aa
2503343
0e0b65a
656b48c
9dc287a
c59e85a
a2aeae4
d0dff31
2d9b797
37b2838
c763ff8
feec77b
988c27f
c98c798
a3ac786
2ae3cbb
3e8226c
b5ed7d0
1ddcf93
95a93a8
ca01c14
af6941a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,7 @@ | |
|
||
<imp> ::= | ||
'import' <id>? '='? <text> | ||
'import' '{' <list(<pat_field>, ';')> '}' '=' <text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed the syntax here ought to simply be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't that allow tuple patterns and all the other things (wildcard and literals)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could insist the pattern is irrefutable, I think, as with shared function args. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, that's what I do. I have also added tests for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @crusso the pattern matches arising from imports have this form (LetD (ObjP (cons (VarP cons)) (nil (VarP nil))) (VarE file$lib/ListM.mo)) but we have little control about the RHS Well, we know a bit about the RHS, after all. It gets built in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay now I reuse the coverage check from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JFTR,
|
||
|
||
<prog> ::= | ||
<list(<imp>, ';')> <list(<dec>, ';')> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cons; nil } = "lib/ListM"; | ||
|
||
//type stack = List<Int>; | ||
let s = cons(1, nil()); | ||
let u = cons<Int>(2, nil<Int>()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Ill-typed intermediate code after Desugaring (use -v to see dumped IR): | ||
(unknown location): IR type error [M0000], subtype violation: | ||
module {type List<T> = ?(T, List<T>); cons : <T>(T, List<T>) -> List<T>; nil : <T>() -> List<T>} | ||
<T>(T, List<T>) -> List<T> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Return code 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- import-module-explicit.run | ||
+++ import-module-explicit.run-ir | ||
@@ -0,0 +1,5 @@ | ||
+Ill-typed intermediate code after Desugaring (use -v to see dumped IR): | ||
+(unknown location): IR type error [M0000], subtype violation: | ||
+ module {type List<T> = ?(T, List<T>); cons : <T>(T, List<T>) -> List<T>; nil : <T>() -> List<T>} | ||
+ <T>(T, List<T>) -> List<T> | ||
+ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- import-module-explicit.run | ||
+++ import-module-explicit.run-low | ||
@@ -0,0 +1,5 @@ | ||
+Ill-typed intermediate code after Desugaring (use -v to see dumped IR): | ||
+(unknown location): IR type error [M0000], subtype violation: | ||
+ module {type List<T> = ?(T, List<T>); cons : <T>(T, List<T>) -> List<T>; nil : <T>() -> List<T>} | ||
+ <T>(T, List<T>) -> List<T> | ||
+ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Ill-typed intermediate code after Desugaring (use -v to see dumped IR): | ||
(unknown location): IR type error [M0000], subtype violation: | ||
module {type List<T> = ?(T, List<T>); cons : <T>(T, List<T>) -> List<T>; nil : <T>() -> List<T>} | ||
<T>(T, List<T>) -> List<T> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Return code 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Ill-typed intermediate code after Desugaring (use -v to see dumped IR): | ||
(unknown location): IR type error [M0000], subtype violation: | ||
module {type List<T> = ?(T, List<T>); cons : <T>(T, List<T>) -> List<T>; nil : <T>() -> List<T>} | ||
<T>(T, List<T>) -> List<T> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Return code 1 |
Uh oh!
There was an error while loading. Please reload this page.