diff options
| author | Brian Campbell | 2019-06-10 17:53:58 +0100 |
|---|---|---|
| committer | Brian Campbell | 2019-06-10 17:53:58 +0100 |
| commit | 3eadd260f7382f98eb7dcbd706a3ed3e910167eb (patch) | |
| tree | ab2d8fec7c2c765abc6af3954c8694bab30a707e /test/typecheck | |
| parent | 534b659d7acccabe7219dc3773f6b09d612bbd86 (diff) | |
Add well-formedness check for type schemes in valspecs.
Fixes #47.
Also adjust the nexp substitution so that the error message points to a
useful location, and replace the empty environment with the initial
environment in a few functions that do type checking to ensure that the
prover is set up (which may be needed for the wf check).
Diffstat (limited to 'test/typecheck')
| -rw-r--r-- | test/typecheck/pass/Replicate/v2.expect | 2 | ||||
| -rw-r--r-- | test/typecheck/pass/existential_ast/v3.expect | 2 | ||||
| -rw-r--r-- | test/typecheck/pass/existential_ast3/v1.expect | 8 | ||||
| -rw-r--r-- | test/typecheck/pass/existential_ast3/v2.expect | 8 | ||||
| -rw-r--r-- | test/typecheck/pass/existential_ast3/v3.expect | 2 | ||||
| -rw-r--r-- | test/typecheck/pass/if_infer/v1.expect | 4 | ||||
| -rw-r--r-- | test/typecheck/pass/if_infer/v2.expect | 4 | ||||
| -rw-r--r-- | test/typecheck/pass/wf_specs.sail | 11 | ||||
| -rw-r--r-- | test/typecheck/pass/wf_specs/wf_specs.expect | 6 | ||||
| -rw-r--r-- | test/typecheck/pass/wf_specs/wf_specs.sail | 10 |
10 files changed, 42 insertions, 15 deletions
diff --git a/test/typecheck/pass/Replicate/v2.expect b/test/typecheck/pass/Replicate/v2.expect index acadd4e2..89ab2910 100644 --- a/test/typecheck/pass/Replicate/v2.expect +++ b/test/typecheck/pass/Replicate/v2.expect @@ -2,7 +2,7 @@ Type error: [[96mReplicate/v2.sail[0m]:13:4-30 13[96m |[0m replicate_bits(x, 'N / 'M) [91m |[0m [91m^------------------------^[0m - [91m |[0m Tried performing type coercion from {('ex119# : Int), true. vector(('M * 'ex119#), dec, bit)} to vector('N, dec, bit) on replicate_bits(x, tdiv_int(__id(N), bitvector_length(x))) + [91m |[0m Tried performing type coercion from {('ex172# : Int), true. vector(('M * 'ex172#), dec, bit)} to vector('N, dec, bit) on replicate_bits(x, tdiv_int(__id(N), bitvector_length(x))) [91m |[0m Coercion failed because: [91m |[0m Mismatched argument types in subtype check [91m |[0m diff --git a/test/typecheck/pass/existential_ast/v3.expect b/test/typecheck/pass/existential_ast/v3.expect index 7bb8a4ab..56b89364 100644 --- a/test/typecheck/pass/existential_ast/v3.expect +++ b/test/typecheck/pass/existential_ast/v3.expect @@ -3,5 +3,5 @@ Type error: 26[96m |[0m Some(Ctor1(a, x, c)) [91m |[0m [91m^------------^[0m [91m |[0m Could not resolve quantifiers for Ctor1 - [91m |[0m [94m*[0m datasize('ex196#) + [91m |[0m [94m*[0m datasize('ex248#) [91m |[0m diff --git a/test/typecheck/pass/existential_ast3/v1.expect b/test/typecheck/pass/existential_ast3/v1.expect index 4b9bd7cc..346b7b75 100644 --- a/test/typecheck/pass/existential_ast3/v1.expect +++ b/test/typecheck/pass/existential_ast3/v1.expect @@ -4,17 +4,17 @@ Type error: [91m |[0m [91m^---------------^[0m [91m |[0m Tried performing type coercion from (int(33), range(0, (2 ^ 5 - 1))) to {('d : Int) ('n : Int), (datasize('d) & (0 <= 'n & ('n + 1) <= 'd)). (int('d), int('n))} on (33, unsigned(a)) [91m |[0m Coercion failed because: - [91m |[0m (int(33), int('ex158#)) is not a subtype of (int('ex153#), int('ex154#)) + [91m |[0m (int(33), int('ex210#)) is not a subtype of (int('ex205#), int('ex206#)) [91m |[0m [[96mexistential_ast3/v1.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (33, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex153# bound here + [91m |[0m [93m |[0m 'ex205# bound here [91m |[0m [[96mexistential_ast3/v1.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (33, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex154# bound here + [91m |[0m [93m |[0m 'ex206# bound here [91m |[0m [[96mexistential_ast3/v1.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (33, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex158# bound here + [91m |[0m [93m |[0m 'ex210# bound here [91m |[0m diff --git a/test/typecheck/pass/existential_ast3/v2.expect b/test/typecheck/pass/existential_ast3/v2.expect index 52eb2f13..7f18c94e 100644 --- a/test/typecheck/pass/existential_ast3/v2.expect +++ b/test/typecheck/pass/existential_ast3/v2.expect @@ -4,17 +4,17 @@ Type error: [91m |[0m [91m^---------------^[0m [91m |[0m Tried performing type coercion from (int(31), range(0, (2 ^ 5 - 1))) to {('d : Int) ('n : Int), (datasize('d) & (0 <= 'n & ('n + 1) <= 'd)). (int('d), int('n))} on (31, unsigned(a)) [91m |[0m Coercion failed because: - [91m |[0m (int(31), int('ex158#)) is not a subtype of (int('ex153#), int('ex154#)) + [91m |[0m (int(31), int('ex210#)) is not a subtype of (int('ex205#), int('ex206#)) [91m |[0m [[96mexistential_ast3/v2.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (31, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex153# bound here + [91m |[0m [93m |[0m 'ex205# bound here [91m |[0m [[96mexistential_ast3/v2.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (31, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex154# bound here + [91m |[0m [93m |[0m 'ex206# bound here [91m |[0m [[96mexistential_ast3/v2.sail[0m]:17:48-65 [91m |[0m 17[96m |[0m if b == 0b0 then (64, unsigned(b @ a)) else (31, unsigned(a)); [91m |[0m [93m |[0m [93m^---------------^[0m - [91m |[0m [93m |[0m 'ex158# bound here + [91m |[0m [93m |[0m 'ex210# bound here [91m |[0m diff --git a/test/typecheck/pass/existential_ast3/v3.expect b/test/typecheck/pass/existential_ast3/v3.expect index 0e43cd52..585cf2c6 100644 --- a/test/typecheck/pass/existential_ast3/v3.expect +++ b/test/typecheck/pass/existential_ast3/v3.expect @@ -3,5 +3,5 @@ Type error: 25[96m |[0m Some(Ctor(64, unsigned(0b0 @ b @ a))) [91m |[0m [91m^-----------------------------^[0m [91m |[0m Could not resolve quantifiers for Ctor - [91m |[0m [94m*[0m (datasize(64) & (0 <= 'ex197# & ('ex197# + 1) <= 64)) + [91m |[0m [94m*[0m (datasize(64) & (0 <= 'ex249# & ('ex249# + 1) <= 64)) [91m |[0m diff --git a/test/typecheck/pass/if_infer/v1.expect b/test/typecheck/pass/if_infer/v1.expect index 011ecbdf..50bd530d 100644 --- a/test/typecheck/pass/if_infer/v1.expect +++ b/test/typecheck/pass/if_infer/v1.expect @@ -5,8 +5,8 @@ Type error: [91m |[0m No overloading for vector_access, tried: [91m |[0m [94m*[0m bitvector_access [91m |[0m Could not resolve quantifiers for bitvector_access - [91m |[0m [94m*[0m (0 <= 'ex115# & ('ex115# + 1) <= 3) + [91m |[0m [94m*[0m (0 <= 'ex166# & ('ex166# + 1) <= 3) [91m |[0m [94m*[0m plain_vector_access [91m |[0m Could not resolve quantifiers for plain_vector_access - [91m |[0m [94m*[0m (0 <= 'ex118# & ('ex118# + 1) <= 3) + [91m |[0m [94m*[0m (0 <= 'ex169# & ('ex169# + 1) <= 3) [91m |[0m diff --git a/test/typecheck/pass/if_infer/v2.expect b/test/typecheck/pass/if_infer/v2.expect index 9a34f688..27b05208 100644 --- a/test/typecheck/pass/if_infer/v2.expect +++ b/test/typecheck/pass/if_infer/v2.expect @@ -5,8 +5,8 @@ Type error: [91m |[0m No overloading for vector_access, tried: [91m |[0m [94m*[0m bitvector_access [91m |[0m Could not resolve quantifiers for bitvector_access - [91m |[0m [94m*[0m (0 <= 'ex115# & ('ex115# + 1) <= 4) + [91m |[0m [94m*[0m (0 <= 'ex166# & ('ex166# + 1) <= 4) [91m |[0m [94m*[0m plain_vector_access [91m |[0m Could not resolve quantifiers for plain_vector_access - [91m |[0m [94m*[0m (0 <= 'ex118# & ('ex118# + 1) <= 4) + [91m |[0m [94m*[0m (0 <= 'ex169# & ('ex169# + 1) <= 4) [91m |[0m diff --git a/test/typecheck/pass/wf_specs.sail b/test/typecheck/pass/wf_specs.sail new file mode 100644 index 00000000..2bacf7e0 --- /dev/null +++ b/test/typecheck/pass/wf_specs.sail @@ -0,0 +1,11 @@ +/* Example from https://github.com/rems-project/sail/issues/47 where a variable + name is mistakenly used at the type level, which wasn't caught before due to + the lack of a well-formedness check on specs. This is the corrected version. + */ + +default Order dec +$include <prelude.sail> + +let 'THIRTY_TWO : atom(32) = 32 + +val f : bits(32) -> bits('THIRTY_TWO) diff --git a/test/typecheck/pass/wf_specs/wf_specs.expect b/test/typecheck/pass/wf_specs/wf_specs.expect new file mode 100644 index 00000000..88844e18 --- /dev/null +++ b/test/typecheck/pass/wf_specs/wf_specs.expect @@ -0,0 +1,6 @@ +Type error: +[[96mwf_specs/wf_specs.sail[0m]:10:25-35 +10[96m |[0mval f : bits(32) -> bits(THIRTY_TWO) + [91m |[0m [91m^--------^[0m + [91m |[0m Undefined synonym THIRTY_TWO + [91m |[0m diff --git a/test/typecheck/pass/wf_specs/wf_specs.sail b/test/typecheck/pass/wf_specs/wf_specs.sail new file mode 100644 index 00000000..bb108ee3 --- /dev/null +++ b/test/typecheck/pass/wf_specs/wf_specs.sail @@ -0,0 +1,10 @@ +/* Example from https://github.com/rems-project/sail/issues/47 where a variable + name is mistakenly used at the type level, which wasn't caught before due to + the lack of a well-formedness check on specs. */ + +default Order dec +$include <prelude.sail> + +let THIRTY_TWO : atom(32) = 32 + +val f : bits(32) -> bits(THIRTY_TWO) |
