Commit Graph

55 Commits

Author SHA1 Message Date
Rob Dockins
097b8a22d2 Update test suite expected output to track changes
in the pretty printer code.
2021-08-06 14:18:12 -07:00
Iavor Diatchki
34b1d87df3 Implementation of nested modules.
* Limitations:
    Does not work in combination parameterized modules, as I am
    about to redo how that works.

  * General refeactorings:
    * Namespaces:
      - We have an explicit type for namespaces, see `Cryptol.Util.Ident`
      - Display environments should now be aware of the namespace of the
        name being displayed.

    * Renamer:
      - Factor out the renamer monad and error type into separate modules
      - All name resultion is done through a single function `resolveName`
      - The renamer now computes the dependencies between declarations,
         orders things in dependency order, and checks for bad recursion.

    * Typechecker: Redo checking of declarations (both top-level and local).
      Previously we used a sort of CPS to add things in scope.   Now we use
      a state monad and add things to the state.  We assume that the renamer
      has been run, which means that declarations are ordered in dependency
      order, and things have unique name, so we don't need to worry about
      scoping too much.

  * Change specific to nested modules:
    - We have a new namespace for module names
    - The interface file of a module contains the interfaces for nested modules
    - Most of the changes related to nested modules in the renamer are
      in `ModuleSystem.NamingEnv` and `ModuleSystem.Rename`
        - There is some trickiness when resolving module names when importing
          submodules (seed `processOpen` and `openLoop`)
    - There are some changes to the representation of modules in the typechecked
      syntax, in particular:
        - During type-checking we "flatten" nested module declarations into
          a single big declaration.  Hopefully, this means that passes after
          the type checker don't need to worry about nested modules
        - There is a new field containing the interfaces of the nested modules,
          this is needed so that when we import the module we know we have the
          nested structure
        - Declarations in functor/parameterzied modules do not appear in the
          flattened list of declarations.  Instead thouse modules are collected
          in a separate field, and the plan is that they would be used from
          there when we implmenet functor instantiation.
2021-03-12 09:55:56 -08:00
Iavor Diatchki
bfad11ba86 Improvements to error messages 2020-11-16 13:29:57 -08:00
Rob Dockins
bccc098a2b Suppress the Must be at least line of defaulting error
messages when the calculated bound is 0.
2020-07-14 10:32:57 -07:00
Rob Dockins
ac3676ddde Fixup test suite 2020-07-02 15:04:07 -07:00
Rob Dockins
e9c22ad0cf Still compute width defaulting information as before, but
use that information to emit error messages rather than warnings.

This provides more specific messages than simply allowing the
affected type variables to remain uninstantiated and failing later.
It also causes some examples that otherwise would have ambiguous
types to fail earlier.  This converts some test instances where
REPL defaulting would eventually succeed into examples that fail
outright instead.  I largely think these instances are improvements.
2020-07-02 15:04:07 -07:00
Rob Dockins
620e62c8e3 Remove all defaulting, except for literals.
Fix up the test suite.  This mostly delays defaulting
warnings into "showing specific instance of polymorpic
type warnings", but requires actual fixes in a small number
of places.  Those places were higly questionable, in my opinion.
2020-07-02 14:56:27 -07:00
Iavor Diatchki
f6213aff33 Improve error messages when we know a constraint will always fail.
This changes the way the special "Error" type is used. The error
message now contains only an explanation of what happened,
and the actual malformed type is the parameter of the error function,
which is always used at kind `k -> k` where `k` is the malformed kind.

This fixes (or at least improves) #768
2020-06-30 20:03:50 -07:00
Iavor Diatchki
0047eaf77a Initial support for floating point computation 2020-06-29 15:31:34 -07:00
Aaron Tomb
47b2eccad7 Remove leading ./ from file names in test output 2019-10-28 13:57:37 -07:00
Iavor Diatchki
8fe9f5efa9 Add support for working with in-memory sources.
Currently we only use this for the Prelude, which is baked into Cryptol.
Previously we used to save it in a temporary file, which would show
up in error messages, leading to bad user experience and unreliable
test outputs.

Also improves the shadowing errors.

Fixes #569
2019-07-05 14:09:04 -07:00
Brian Huffman
9b7597c4fd Update changed test output. 2018-12-11 15:52:19 -08:00
Brian Huffman
f609b36225 Rename primitive demote to the more self-explanatory name number.
The name "demote" is only meaningful to those who already know what
the Cryptol primitive does. Also, due to recent changes in the error
and warning messages, the name "demote" is showing up much more often
in REPL output. For example:

    Defaulting type argument 'rep' of 'demote' to [2]

    Showing a specific instance of polymorphic result:
      * Using 'Integer' for type argument 'rep' of 'Cryptol::demote'

These messages will hopefully be made less confusing to non-experts
if the name "demote" is replaced with "number".
2018-07-27 13:52:57 -07:00
Iavor Diatchki
4c6a69c0cf Improvements to naming of variables.
This does a bunch of small changes, that should improve the usability
of Cryptol.  Namely:
  * When we are forced to make up a name, pick something derived from
    the source of the variable, annotated with the unique.
  * When pretty printing a schema, use "n,m,i,j,k" for numeric variables
    and "a,b,c,d,e" for value type vairable.
  * When generalizing, put numeric vairables first.
2018-06-28 15:58:11 -07:00
Iavor Diatchki
75b56e251e Complain when we spot invalid literals. Fixes #519 2018-06-28 14:13:07 -07:00
Iavor Diatchki
0bf36808ed Improve various defaulting/instantiatiation warnings and error messages. 2018-06-25 16:48:10 -07:00
Iavor Diatchki
0d81f0ba25 Implement defaulting in the presence of overloaded literals. 2018-06-20 15:06:19 -07:00
Iavor Diatchki
e579113d05 Merge remote-tracking branch 'origin/master' into literal-class
# Conflicts:
#	tests/mono-binds/test04.icry.stdout
#	tests/regression/check01.icry.stdout
#	tests/regression/check16-tab.icry.stdout
#	tests/regression/check16.icry.stdout
#	tests/regression/check21.icry.stdout
#	tests/regression/check22.icry.stdout
2018-06-20 09:14:17 -07:00
Iavor Diatchki
33f0ab3979 Improved locations for defaulting warnings. 2018-06-19 17:28:59 -07:00
Brian Huffman
cc478e8684 Update test output. 2018-06-15 14:20:27 -07:00
Brian Huffman
e512dc2c17 Update test case output. 2018-06-15 14:15:39 -07:00
Brian Huffman
b3df205e04 Adapt test output to new primitives. 2018-06-15 10:18:02 -07:00
Brian Huffman
570f0be2ea Remove redundant fin constraint from the type of demote.
`fin bits` and `bits >= width val` together imply `fin val`.
2018-06-14 12:33:20 -07:00
Brian Huffman
50f54c9610 Fix test output due to addition of new primitive. 2018-06-14 06:22:59 -07:00
Brian Huffman
ab000984d2 Remove redundant prelude functions not, extend, and extendSigned.
These were recently moved here from Cryptol::Extras. They are duplicates
of existing functions `complement`, `zext`, and `sext`.

See #427.
2018-05-24 14:41:09 -07:00
Aaron Tomb
c42a135fce Update tests to account for Cryptol::Extras merge 2018-05-24 09:23:17 -07:00
Brian Huffman
3be72ae2cb Replace indexing primitives (!!) and (@@) with cryptol implementations. 2018-04-18 16:50:39 -07:00
Brian Huffman
2cdf9bd159 Replace primitives pmult, pmod, pdiv with cryptol implementations. 2018-04-15 06:56:20 -07:00
Brian Huffman
5cd9141fe7 Add functions head and last to Cryptol prelude. Fixes #465.
Also fix regression test output.
2018-03-16 15:10:36 -07:00
Brian Huffman
cce32a4868 Merge branch 'master' into integer
This brings the Logic and Zero type classes into the integer branch.
2017-09-28 13:18:27 -07:00
Brian Huffman
1ed5640339 Merge branch 'master' into logic-class
# Conflicts:
#	tests/mono-binds/test05.icry.stdout
2017-09-26 16:50:53 -07:00
Iavor Diatchki
60523d5986 Delete old solver stuff.
The main user visible effect of this might be that sometime things on
the Cryptol command line are instantiated in a slightly different way:
we get `inf` sometimes when we got a finite example before.

We could work around this if it is an issue, but I am not sure which
behavior is more reasonable.
2017-09-26 14:02:52 -07:00
Brian Huffman
35423d0243 Update test output. 2017-09-15 16:38:03 -07:00
Brian Huffman
860060c085 Fix test output. 2017-09-15 14:05:27 -07:00
Brian Huffman
5332d98261 Fix test output 2017-09-13 17:04:52 -07:00
Robert Dockins
ef047d3a19 Fix test breakage due to new operations in the Cryptol prelude. 2017-08-16 17:37:24 -07:00
Iavor Diatchki
771c2deaa1 Slightly different error messages, should be OK. 2017-07-10 11:06:14 -07:00
Aaron Tomb
e282c65a7e Fix test failures from latest type checker changes
Recent changes resolved issue 002, so we no longer need to indicate that
it's expected to fail. Other small changes to the type checker have
made things like type variable numbers change slightly.
2017-06-20 10:08:36 -07:00
Brian Huffman
9a267b1f0c Removed definition of binary infix (~) from Cryptol prelude. Fixes #423.
This change partially reverts changeset c620cbf2, which fixed #296,
which was about supporting `:t (~)` in the REPL.

As of this change, `:t (~)` will no longer work in the REPL.
The regression test for issue #296 is removed.
2017-05-24 09:39:50 -07:00
Iavor S. Diatchki
2c3145a417 Fix some of the broken tests. 2017-02-08 17:24:15 -08:00
Robert Dockins
3becedd910 Update tests to remove spurious failures 2016-08-18 16:05:23 -07:00
Brian Huffman
0024dd0300 Update test output 2016-08-10 13:49:09 -04:00
Adam C. Foltzer
2c428804bc remove splitBy and update documentation
Closes #291
2016-07-05 09:58:49 -07:00
Trevor Elliott
3c59bf3231 Update the test output for mono-bind test 4
The type variable name was the only change.
2016-05-31 11:51:01 -07:00
Trevor Elliott
f8e6582230 Update tests and output 2015-09-28 21:26:26 -07:00
Trevor Elliott
b4fbec108e Update some test output
The core AST now always prints fully-qualified names.
2015-09-27 19:56:58 -05:00
Iavor S. Diatchki
c9e4fab6a8 Fix up tests. 2015-08-12 15:52:18 -07:00
Trevor Elliott
4d469fa2ce Update test output 2015-06-29 16:34:11 -07:00
Trevor Elliott
7e8940e9a8 Name changes in debug output 2015-06-09 14:27:43 -07:00
Trevor Elliott
ae6b5dc3e8 Add support for user-defined infix operators
Squashed commit of the following:

commit 9f03b7cd1a1f169ea192d735890fd6a3503ecb39
Author: Trevor Elliott <trevor@galois.com>
Date:   Wed Jun 3 11:40:27 2015 -0700

    Add a test for user-defined infix operators

commit 31656a4640e8189b880fa1ce39779c07872ebe18
Author: Trevor Elliott <trevor@galois.com>
Date:   Wed Jun 3 11:39:43 2015 -0700

    Forgot to initialize some fields in the parser

commit 73bcb2e5961691f2258f5a7a12ee2dc92d1a1ad3
Author: Trevor Elliott <trevor@galois.com>
Date:   Wed Jun 3 11:20:40 2015 -0700

    Fix unnecessary panics in the renamer

commit 03cd8130901fb7aeb12d41cc03ce970ce6571423
Author: Trevor Elliott <trevor@galois.com>
Date:   Mon Jun 1 01:29:36 2015 -0700

    Remove a debug print

commit 2934a56b31d51ac971204d3fea9f62bf8829573d
Author: Trevor Elliott <trevor@galois.com>
Date:   Mon Jun 1 01:26:32 2015 -0700

    User-defined operators

commit 47f4b37fc75accaf0284addc2382c341167b8b6b
Author: Trevor Elliott <trevor@galois.com>
Date:   Sun May 31 23:44:51 2015 -0700

    Parse signatures for infix operators

commit a1a11705c2eec6e669159756de2eb2cb19bcfa83
Author: Trevor Elliott <trevor@galois.com>
Date:   Sun May 31 23:28:56 2015 -0700

    Plumb fixity information through

commit 56134ac0d9fb919f280dabfcdab6506195816340
Author: Trevor Elliott <trevor@galois.com>
Date:   Sun May 31 22:03:55 2015 -0700

    Parse fixity declarations

commit f2db0ad5d47d478799dabf03a6cad9be7aec2191
Author: Trevor Elliott <trevor@galois.com>
Date:   Fri May 29 16:00:57 2015 -0700

    Update test output for location changes

commit 15949018865d3ac8efca1a081334a7213c25775c
Merge: 1bd7f16 52f3a83
Author: Trevor Elliott <trevor@galois.com>
Date:   Fri May 29 15:36:20 2015 -0700

    Merge remote-tracking branch 'origin/master' into wip/infix-operators

commit 1bd7f1602bd6bbf5693871f01ca65a4cf3ed3bf8
Author: Trevor Elliott <trevor@galois.com>
Date:   Fri May 29 15:30:14 2015 -0700

    Forgot to consider EParens in translateExprToNumT

commit d63435270d5ca5bdf37584e4781a655a685c9c3b
Author: Trevor Elliott <trevor@galois.com>
Date:   Fri May 29 15:29:47 2015 -0700

    Add | to the operator character set

commit 7be23372c4625bf20b8f8ccf94a148563417f6cb
Author: Trevor Elliott <trevor@galois.com>
Date:   Fri May 29 14:49:07 2015 -0700

    Fix the printing of #Uniq variables

commit f9110e159aa0c3ae7450fe7a4db2a8d275d9bc1a
Author: Trevor Elliott <trevor@galois.com>
Date:   Thu May 28 17:04:26 2015 -0700

    Fix some failing tests

commit 0582fd08cc402c7bfd2de2c02df14fa77906e37e
Author: Trevor Elliott <trevor@galois.com>
Date:   Thu May 28 16:12:18 2015 -0700

    Remove more primitives from the parser

commit f5dafd1ea7954b64f7949c754e0c94abd2598679
Author: Trevor Elliott <trevor@galois.com>
Date:   Wed May 27 18:02:52 2015 -0700

    Do fixity resolution during renaming
2015-06-03 11:42:33 -07:00