diff options
| author | Alasdair Armstrong | 2018-07-26 16:30:59 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-07-26 16:53:07 +0100 |
| commit | 4861ebb08ccd3e13af19b9c12f2164b66a5d2bb0 (patch) | |
| tree | bdd294f3d0efc80ab7833c192c72ed7f345169e5 /test/typecheck | |
| parent | 92373cfb9dd6a9a3d450a315d462378b7de20a71 (diff) | |
Some tweaks to not and or patterns
- Fix ambiguities in parser.mly
- Ensure that no new identifiers are bound in or-patterns and
not-patterns, by adding a no_bindings switch to the
environment. These patterns shouldn't generate any bogus flow typing
constraints because we just pass through the original environment
without adding any possible constraints (although this does mean we
don't get any flow typing from negated numeric literals right now,
which is a TODO).
- Reformat some code to match surrounding code.
- Add a typechecking test case for not patterns
- Add a typechecking test case for or patterns
At least at the front end everything should work now, but we need to
do a little bit more to rewrite these patterns away for lem etc.
Diffstat (limited to 'test/typecheck')
| -rw-r--r-- | test/typecheck/pass/not_pattern.sail | 14 | ||||
| -rw-r--r-- | test/typecheck/pass/not_pattern/v1.expect | 5 | ||||
| -rw-r--r-- | test/typecheck/pass/not_pattern/v1.sail | 15 | ||||
| -rw-r--r-- | test/typecheck/pass/or_pattern.sail | 16 | ||||
| -rw-r--r-- | test/typecheck/pass/or_pattern/v1.expect | 5 | ||||
| -rw-r--r-- | test/typecheck/pass/or_pattern/v1.sail | 14 |
6 files changed, 69 insertions, 0 deletions
diff --git a/test/typecheck/pass/not_pattern.sail b/test/typecheck/pass/not_pattern.sail new file mode 100644 index 00000000..818b1b82 --- /dev/null +++ b/test/typecheck/pass/not_pattern.sail @@ -0,0 +1,14 @@ +default Order dec + +$include <prelude.sail> + +let x : int = 5 + +val main : unit -> unit + +function main() = { + match x { + ~(3) => (), + _ => () + } +}
\ No newline at end of file diff --git a/test/typecheck/pass/not_pattern/v1.expect b/test/typecheck/pass/not_pattern/v1.expect new file mode 100644 index 00000000..9de82d1f --- /dev/null +++ b/test/typecheck/pass/not_pattern/v1.expect @@ -0,0 +1,5 @@ +Type error at file "not_pattern/v1.sail", line 12, character 7 to line 12, character 7 + + ~([41my[0m) => (), + +Bindings are not allowed in this context diff --git a/test/typecheck/pass/not_pattern/v1.sail b/test/typecheck/pass/not_pattern/v1.sail new file mode 100644 index 00000000..490e9856 --- /dev/null +++ b/test/typecheck/pass/not_pattern/v1.sail @@ -0,0 +1,15 @@ +default Order dec + +$include <prelude.sail> + +let x : int = 5 + +val main : unit -> unit + +function main() = { + match x { + ~(3) => (), + ~(y) => (), + _ => () + } +}
\ No newline at end of file diff --git a/test/typecheck/pass/or_pattern.sail b/test/typecheck/pass/or_pattern.sail new file mode 100644 index 00000000..a6e11ecd --- /dev/null +++ b/test/typecheck/pass/or_pattern.sail @@ -0,0 +1,16 @@ +default Order dec + +$include <prelude.sail> + +let x : int = 5 + +val main : unit -> unit + +function main() = { + match x { + 3 | 4 => (), + (1 | 2) | 3 => (), + 1 | (2 | 3) => (), + _ => () + } +}
\ No newline at end of file diff --git a/test/typecheck/pass/or_pattern/v1.expect b/test/typecheck/pass/or_pattern/v1.expect new file mode 100644 index 00000000..edf07f03 --- /dev/null +++ b/test/typecheck/pass/or_pattern/v1.expect @@ -0,0 +1,5 @@ +Type error at file "or_pattern/v1.sail", line 11, character 5 to line 11, character 5 + + [41my[0m | z => (), + +Bindings are not allowed in this context diff --git a/test/typecheck/pass/or_pattern/v1.sail b/test/typecheck/pass/or_pattern/v1.sail new file mode 100644 index 00000000..21bc87e8 --- /dev/null +++ b/test/typecheck/pass/or_pattern/v1.sail @@ -0,0 +1,14 @@ +default Order dec + +$include <prelude.sail> + +let x : int = 5 + +val main : unit -> unit + +function main() = { + match x { + y | z => (), + _ => () + } +}
\ No newline at end of file |
