summaryrefslogtreecommitdiff
path: root/test/typecheck
AgeCommit message (Collapse)Author
2021-01-05Enum value feature request for AlexandreAlasdair
2021-01-05Don't allow type synonyms with the same name as existing typesAlasdair
2020-11-25Remove bogus pattern completeness warning on singleton enums and unionsBrian Campbell
2020-11-25Fix Lem output for single element enumBrian Campbell
2020-09-25tests: Move copy-pasted code into a shared helper .shAlex Richardson
Also fix a few shellcheck warnings related to printf while doing so.
2020-08-06Forbid duplicate top-level letbindingsAlasdair
2020-07-15Update duplicate ctor warningAlasdair
2020-07-15Add test files missed from last commitMark Wassell
2020-06-17Make `if cond { ... return() };` assert cond in the type environmentBrian Campbell
Avoids generating an assert expression with an escape effect. Mirrors existing case for `if cond { throw(...); };`. No longer requires `-non_lexical_flow`.
2020-06-17Add test for if-return patternBrian Campbell
(currently supported in nl_flow)
2020-06-05Generate nice error messages for patterns woth duplicate bindingsAlasdair
2020-05-21Merge branch 'sail2' into mono-tweaksAlasdair
2020-05-15Update type error messages for jenkinsAlasdair
Location info fixes changed the location reported for an expected type error very slightly
2020-04-28Update test error messages, hopefully will make Jenkins happy againAlasdair
2020-04-21Tweak types of loop combinators for prover combinatorsThomas Bauereiss
Split the variable (tuple) type into an input and output type. They are meant to be the same, but due to the way function types are instantiated, unification can fail in the case of existential types, as in the added test case (when trying to generate Lem definitions from it). The output of the loop will be checked against the expected type, though, due to a type annotation outside the loop added by the rewrite pass for variable updates.
2020-04-10Make bounds check for vector subrange assignments stricterThomas Bauereiss
Check that indices are within bounds, not just in the right (increasing/decreasing) order.
2020-04-10Be more careful when flow-typing loopsThomas Bauereiss
Asserting constraints from the loop condition in the body is fine for while-loops, but doesn't make sense for until-loops.
2020-03-19Improve a particularly unhelpful type errorAlasdair
From: No type variable 'ex14# to: Type error: [../and_let_bool.sail]:6:19-50 6 | and_bool(let y : bool = x in not_bool(y), x) | ^-----------------------------^ | The type variable 'ex14# would leak into an outer scope. | | Try adding a type annotation to this expression. | This error was caused by: | [../and_let_bool.sail]:6:23-24 | 6 | and_bool(let y : bool = x in not_bool(y), x) | | ^ | | Type variable 'ex14# was introduced here |
2020-03-18Expose details of failed lexp bounds checksThomas Bauereiss
Allows ASL-to-Sail translation to automatically patch lexp bounds check errors.
2020-02-24Allow overloading of subrange builtins for non-bitvectorsThomas Bauereiss
2020-02-21Make sure we test that struct literals have a complete set of fields. Fixes #60Alasdair Armstrong
2020-01-31Fix soundness bug found by MarkAlasdair
When returning a type from a letbinding we need to be careful that the type it returns does not refer to any type variable that only exists for the lifetime of the letbinding (because it was bound by it). Normally this fails because any type variable bound in the inner letbinding won't exist in the outer scope, but if it is shadowed this can cause an issue.
2020-01-16Allow effects on mappingsAlasdair Armstrong
2019-12-10Introduce new bitfield syntax for ASL translationAlasdair Armstrong
Now we less desugared ASL we'd like to translate some notions more idiomatically, such as bitfields with names. However the current bitfield implementation in Sail is really ugly (entirely my fault) This commit introduces a new flag -new_bitfields which changes the behavior of bitfields as follows bitfield B : bits(32) = { Field: 7..0 } Is now treated as a struct with a single field called `bits` register R : B function main() -> unit = { R[Field] = 0xFF; assert(R[Field] == 0xFF) } then desugars as R.bits[7..0] = 0xFF and assert(R.bits[7..0] == 0xFF) which is much simpler, matches ASL and is probably how it should have worked all along
2019-11-05Forbid types declared after a scattered union being used in clausesAlasdair
The following is therefore always forbidden ``` scattered union U enum E = A | B | C union clause U = Ctor : E ``` We attempt to detect when this occurs and include a hint indicating the likely reason why a 'Undefined type E' error might occur in this circumstance
2019-11-05Improve type error for recursive types slightlyAlasdair Armstrong
2019-11-05Make sure we correctly forbid recursive datatypes that we don't want to supportAlasdair Armstrong
Ensure we give a nice error message that explains that recursive types are forbidden ``` Type error: [struct_rec.sail]:3:10-11 3 | field : S | ^ | Undefined type S | This error was caused by: | [struct_rec.sail]:2:0-4:1 | 2 |struct S = { | |^----------- | 4 |} | |^ | | Recursive types are not allowed ``` The theorem prover backends create a special register_value union that can be recursive, so we make sure to special case that.
2019-11-01Add a missing well-formedness checkAlasdair
2019-08-14Update testsThomas Bauereiss
2019-08-02Fix up some edge cases with the bitvector/polyvector splitBrian Campbell
Mostly in the Coq backend, plus a few testcases that use bitvector builtins on poly-vectors (which works on some backends, but not Coq). Also handle some additional list inclusion proofs in Coq.
2019-07-17Add another test caseAlasdair Armstrong
2019-07-16Merge remote-tracking branch 'origin/sail2' into separate_bvAlasdair Armstrong
2019-06-18Update test casesThomas Bauereiss
2019-06-10Add well-formedness check for type schemes in valspecs.Brian Campbell
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).
2019-06-05Add some regression testsAlasdair
2019-06-04Merge branch 'sail2' into separate_bvAlasdair Armstrong
2019-05-28Fix typechecking test expected errorAlasdair Armstrong
2019-05-17Experiment with making vector and bitvector distinct typesAlasdair Armstrong
Only change that should be needed for 99.9% of uses is to change vector('n, 'ord, bit) to bitvector('n, 'ord), and adding $ifndef FEATURE_BITVECTOR_TYPE type bitvector('n, dec) = vector('n, dec, bit) $endif for to support any Sail before this Currently I have all C, Typechecking, and SMT tests passing, as well as the RISC-V spec building OCaml and C completely unmodified.
2019-05-14Fix test case for previous commitAlasdair Armstrong
Previous commit changed the bitfield desugaring very slightly which this test case relied upon.
2019-05-14Various bugfixesAlasdair Armstrong
Since we have __deref to desugar *x in this file (as it's the one file everything includes) we might as well add a __bitfield_deref here too, for the bitfield setters. Make sure undefined_nat can be used in C Both -memo_z3 and -no_memo_z3 were listed as default options, now only -no_memo_z3 is listed as the default.
2019-05-14Add feature that allows functions to require type variables are constantAlasdair Armstrong
can now write e.g. forall (constant 'n : Int) rather than forall ('n: Int) which requires 'n to be a constant integer value whenever the function is called. I added this to the 'addrsize variable on memory reads/writes to absolutely guarantee in the SMT generation that we don't have to worry about the address being a variable length bitvector.
2019-05-07Merge branch 'sail2' into smt_experimentsAlasdair Armstrong
2019-04-26Fix boolean short-circuiting operators causing some flow-typing unsoundnessAlasdair Armstrong
2019-04-15Fix: Allow zero-length vector literalsAlasdair Armstrong
2019-04-06Various bugfixes and improvementsAlasdair
- Rename DeIid to Operator. It corresponds to operator <string> in the syntax. The previous name is from when it was called deinfix in sail1. - Removed things that weren't actually common from pretty_print_common.ml, e.g. printing identifiers is backend specific. The doc_id function here was only used for a very specific use case in pretty_print_lem, so I simplified it and renamed it to doc_sia_id, as it is always used for a SIA.Id whatever that is. - There is some support for anonymous records in constructors, e.g. union Foo ('a : Type) = { MkFoo : { field1 : 'a, field2 : int } } somewhat similar to the enum syntax in Rust. I'm not sure when this was added, but there were a few odd things about it. It was desugared in the preprocessor, rather than initial_check, and the desugaring generated incorrect code for polymorphic anonymous records as above. I moved the code to initial_check, so the pre-processor now just deals with pre-processor things and not generating types, and I fixed the code to work with polymorphic types. This revealed some issues in the C backend w.r.t. polymorphic structs, which is the bulk of this commit. I also added some tests for this feature. - OCaml backend can now generate a valid string_of function for polymorphic structs, previously this would cause the ocaml to fail to compile. - Some cleanup in the Sail ott definition - Add support for E_var in interpreter previously this would just cause the interpreter to fail
2019-03-22Tidy up of div and mod operators (C implementation was previously ↵Robert Norton
inconsistent with ocaml etc.). Rename div and mod builtins to ediv_int/emod_int and tdiv_int/tmod_int and add corresponding implementations. Add a test with negative operands. This will break existing models but will mean users have to think about which versions they want and won't accidentally use the wrong one.
2019-03-15Fix testsThomas Bauereiss
2019-03-14Add various useful methods to interactive modeAlasdair Armstrong
:def <definition> evaluates a top-level definition :(b)ind <id> : <type> creates an identifier within the interactive type-checking environment :let <id> = <expression> defines an identifier Using :def the following now works and brings the correct vector operations into scope. :def default Order dec :load lib/prelude.sail Also fix a type-variable shadowing bug
2019-03-08Fix: Never consider single variable types to be ambiguousAlasdair
2019-03-05Add forgotten recursive function testBrian Campbell