Commit Graph

719 Commits

Author SHA1 Message Date
Eric Mertens
c7504ea3c9
renderOneLine should render to one line (#1759)
renderOneLine should render to one line

Previously the implementation was using layoutCompat with the hope that this operation rendered to a single line. It doesn't. This function is only used in the obscure :dumptests command where rendering to a single line is important for the file format.
2024-10-01 16:05:24 -07:00
Eric Mertens
8cd51e8249
Allow doctests to span multiple lines with a trailing \ like the REPL already supports (#1757)
* Allow doctests to span multiple lines with a trailing \ like the REPL already supports
* Empty doctest lines to be skipped without error
2024-09-27 13:24:51 -07:00
Ryan Scott
16d2786c7d Fix splitV when splitting empty sequence to type [inf][0]
Previously, `splitV` would assume that if you were splitting a value `val` into
something of type `[inf][each]`, then `val` must be a stream of type of `[inf *
each]` (i.e., of type `[inf]`). This is not true in the corner case where
`each` equals `0`, however. In that case, `val` is of type `[0]`, which is a
word, not a stream. As such, we need to ensure that we do not call `fromSeq` on
`val`, which crashes if `val` is not a stream or sequence.

Fixes #1749.
2024-09-18 14:37:04 -04:00
Eric Mertens
98c5cf6e9a
Limit :check to return only locally defined properties (#1731) 2024-09-16 09:34:08 -07:00
Eric Mertens
688e4782ce
Gracefully skip checking docstrings on interface modules (#1734) 2024-08-20 08:49:31 -07:00
Eric Mertens
2fb70e61c5
Gracefully skip docstrings on top-level functors (#1730) 2024-08-13 14:43:15 -07:00
Eric Mertens
1f6f880318
Functor docstrings (#1726)
* Fix docstring behaviors around functors

- Don't duplicate docstrings onto modules generated by the desugarer
- Combine docstrings when instantiating a functor to preserve both the instance and the instantiated documentation

* Suppress :check-docstring output for definitions without fences
2024-08-13 11:23:00 -07:00
Eric Mertens
df4c9df73c
Initial implementation of check docstrings from python (#1712)
* Initial implementation of "check docstrings" from python

* Improve and synchronize the unlit and docstring code fence parser to better match GitHub markdown syntax

* Associate identifiers with docstring comes from

* Add :set proverTimeout support for goal-level timeouts

* Adds and evaluates docstrings on top-level module declarations
2024-08-06 08:07:41 -07:00
Eric Mertens
c650eb28ed
Propagate nested relation when instantiating functors (#1720) 2024-08-02 14:34:17 -07:00
Ryan Scott
dd9ba9c028 Implement Float's Literal instance in the reference evaluator
Also extend the `float_reference_eval` test case to ensure that the reference
evaluator covers all of `Float`'s instances.

Fixes #1715.
2024-07-31 12:41:21 -04:00
Ryan Scott
a11dff9846 Implement all floating-point primitives in reference evaluator
This ensures that all of the primitives defined in `lib/Float.cry` are
supported in Cryptol's reference evaluator. Moreover, this removes the
primitive table entry for `fpIsFinite`, as `fpIsFinite` is not defined as a
primitive and therefore doesn't need special treatment.

I have added a `tests/regression/float_reference_eval.icry` test case which
ensures that the reference evaluator does the expected thing on all
floating-point operations.

Fixes #1714.
2024-07-31 12:41:21 -04:00
Ryan McCleeary
bb77d9f1dc Enhance TypeCheck to reason more about exponents.
Add (x >= 2, x^a * x^b = x^c => a + b = c) to Numeric.hs.
Add (Nat a, a * a^x = a^y => 1 + x = y) to SimpType.hs
Add (x >= 2,  x^a >= x^b => a >= b) to Numeric.hs

Start adding tests for exponent TC checks.
2024-07-30 09:35:02 -06:00
Eric Mertens
009907ed91
Improve :check-docstrings (#1706)
* Document docstring comments in reference manual
* Handle more expected cases of prefix stripping in docstring comments
* Catch REPL exceptions when checking docstrings
2024-07-23 09:43:43 -07:00
Eric Mertens
4ca062966e
Initial implementation of :check-docstrings (#1682)
* Update all commands to track their results

* Implement REPL :check-docstrings command

This command checks that all of the unlabeled and "repl" labeled
codeblocks in docstrings can successfully evaluate as REPL commands.

Cryptol will now indicate exit failure if any of REPL commands fail,
making it possible to use in automated testing.

:check-docstrings internal implementation is set up to track results
of subcommands in support for integration into a remote server API
endpoint.

* Implement :focus

* Add some :check-docstring test cases

* Update changelog

* Update CrashCourse.tex now that more commands are checked

* Require repl and convert \r\n to \n in lexer
2024-07-18 15:44:16 -07:00
Ryan
dd112501ca Remove unnecessary line from issue1675 test. 2024-07-10 15:02:15 -06:00
Ryan
84194fc187 Issue#1675, add failing test for ec_mult as y should be 0 rather than 13. 2024-07-10 10:13:11 -06:00
Ryan Scott
97e972b025
Merge pull request #1695 from GaloisInc/issue1593-issue1693
Abort early after type-checking malformed constraint guards
2024-07-03 12:41:23 -04:00
Iavor Diatchki
d0a98a545b Make fixes for 1691 work with more nested modules. 2024-07-03 08:57:52 -07:00
Ryan Scott
6e417aa3d1 Abort early after type-checking malformed constraint guards
Checking ill-typed constraint guards for exhaustivity can cause Cryptol to
panic. If we detect any type errors after type-checking the guards, we now
abort early and report any recorded errors instead of proceeding to check
exhaustivity.

Fixes #1593. Fixes #1693.
2024-07-02 07:16:05 -04:00
Iavor Diatchki
128411e605 Merge branch 'master' into issue_1691
# Conflicts:
#	CHANGES.md
2024-07-01 09:57:15 -07:00
Iavor Diatchki
efa9dd1742 Fix test for Windows. 2024-07-01 09:55:04 -07:00
Ryan Scott
fbbbb8f56f
Check for syntactically invalid constraint guards in the parser (#1686)
Numeric constraint guards have very particular syntactic requirements:

* They must always be used in top-level definitions.
* Their definitions must always be accompanied by a top-level type signature.

Previously, we checked these requirements in a combination of places in the
parser and the typechecker. The checks in the typechecker weren't very
thorough, however, and they failed to catch local definitions without type
signatures that use constraint guards, as seen in #1685.

This patch moves all of these syntactic checks to the parser (in
`Cryptol.Parser.ExpandPropGuards`). We now recurse into expressions to check
for local definition that use constraint guards and error if we encounter one.
This ensures that by the time we reach the typechecker, all constraint guard
expressions are at least syntactically valid.

Fixes #1685.
2024-07-01 07:13:36 -04:00
Iavor Diatchki
84648390b7 Add a test 2024-06-28 04:39:19 -07:00
Iavor Diatchki
e98f4d6e28 Only add implicit imports for non-anonymous modules 2024-06-28 04:39:05 -07:00
Eric Mertens
823ed91fc7 Update docs.cry test to show preserved doctests 2024-06-03 10:09:40 -07:00
Iavor Diatchki
d6eed17be5 More test fixes 2024-06-02 07:13:27 -07:00
Iavor Diatchki
c77db36a25 Update mingw test 2024-06-02 04:20:31 -07:00
Iavor Diatchki
a9f962a5e7 Fix darwin test 2024-06-02 04:16:37 -07:00
Iavor Diatchki
d599934038 Fix tests 2024-06-01 03:04:15 -07:00
Ryan Scott
f380e1084d Fix roundAway implementation in reference evaluator
This synchronizes the implementation of `roundAway` in the reference evaluator
with the implementation of `Cryptol.Backend.FloatHelpers.floatToInteger`, which
expects `NearAway` rather than `Away`.

Fixes #1663.
2024-05-31 10:16:45 -04:00
Ryan
fe5e9bdb1e Revert "Only grab public IfaceDecls from other modules."
This reverts commit 19ebc256f8.
2024-04-01 08:58:30 -06:00
Ryan
ed7776de2e Add failing test for issue-#1649 2024-04-01 08:58:22 -06:00
Ryan Scott
1e1c14c28a Implement coreLint for numeric constraint guards
This ensures that the constraints and right-hand side expressions in each guard
are well formed. This check suffices to catch the bug in
https://github.com/GaloisInc/saw-script/issues/2043, which was fixed separately
in a previous commit.

I have also updated the `tests/constraint-guards/type-sig-constraint.icry` test
to use `coreLint=on` rather than checking `debug` output, as the former is more
resilient to internal changes in Cryptol's pretty-printer.

Fixes #1647.
2024-03-25 13:13:00 -04:00
Ryan Scott
092a7f088b Fix typechecking of constraint guards with type signature constraints
Previously, `checkPropGuardCase` would not consider type signature constraints
when determining how many proof applications to generate, which ultimately led
to the issues observed in https://github.com/GaloisInc/saw-script/issues/2043.
This is relatively easy to fix by ensuring that we pass these constraints as an
additional argument to `checkPropGuardCase`.

It is difficult to fully validate that this fix works without SAW, but I have
checked in a smoke test that checks if the guards in a numeric constraint guard
definition have the expected number of proof applications.
2024-03-25 12:26:34 -04:00
Ryan
19ebc256f8 Only grab public IfaceDecls from other modules. 2024-03-19 14:35:37 -06:00
Ryan Scott
ca0eb7e064 Fix handling of abstract types
We must treat built-in abstract types slightly differently from user-defined
abstract types.

Also fix a bug in the way that the return kind of primitive types are computed:
we previously said that they all return `*`, but this is not necessarily the
case.
2024-02-02 16:02:31 -05:00
Ryan Scott
a9e35fe004 Update .stdout.mingw32 and .stdout.darwin files 2024-02-01 20:39:51 -05:00
Ryan Scott
f825abd2e1 Update expected stdout for test cases 2024-02-01 19:35:16 -05:00
Iavor Diatchki
3e7d786a15 Implement sanity checking for case
Fixes #1615
2024-01-31 12:01:52 -08:00
Iavor Diatchki
e5251eef98 Add nominal type constructors in scope.
Fixes #1617
2024-01-31 11:21:39 -08:00
Iavor Diatchki
684a85ed18 Tweak error messages 2024-01-31 10:36:13 -08:00
Iavor Diatchki
e47ebcbc8a Improvements to ":help" for nominal types/constructors
Fixes #1605
2024-01-31 10:03:02 -08:00
Ryan Scott
0c88cc328d Add regression test for #1606 2024-01-28 17:18:36 -05:00
Ryan Scott
d965cb44ae Emit an error for non-exhaustive case expressions
Fixes #1608.
2024-01-28 17:15:55 -05:00
Ryan Scott
ca85fac6b3 Error when default case overlaps with subsequent cases 2024-01-26 10:51:55 -05:00
Ryan Scott
82526569eb Generalize CheckEnum test case to include :prove commands 2024-01-25 15:06:35 -05:00
Ryan Scott
77a840621b Fix precedence when pretty-printing counterexamples 2024-01-23 17:22:05 -05:00
Ryan Scott
c00c9e5775 Implement toExpr for enums 2024-01-23 17:06:09 -05:00
Ryan Scott
f0706f9ed9 Test case for :check'ing enum values 2024-01-23 15:10:28 -05:00
Ryan Scott
e6291cee56 Update issue1040 golden output 2024-01-23 13:03:24 -05:00