Commit Graph

688 Commits

Author SHA1 Message Date
G. Allais
c1ebc0535d
[ new ] semantic highlighting in REPL & holes (#1836) 2021-08-13 16:00:54 +01:00
G. Allais
21c6f4fb79
[ breaking ] remove parsing of dangling binders (#1711)
* [ breaking ] remove parsing of dangling binders

It used to be the case that

```
ID : Type -> Type
ID a = a

test : ID (a : Type) -> a -> a
test = \ a, x => x
```

and

```
head : List $ a -> Maybe a
head [] = Nothing
head (x :: _) = Just x
```

were accepted but these are now rejected because:

* `ID (a : Type) -> a -> a` is parsed as `(ID (a : Type)) -> a -> a`
* `List $ a -> Maybe a` is parsed as `List (a -> Maybe a)`

Similarly if you want to use a lambda / rewrite / let expression as
part of the last argument of an application, the use of `$` or parens
is now mandatory.

This should hopefully allow us to make progress on #1703
2021-08-10 19:24:32 +01:00
Tim Engler
be37e5b458 Added "lookupBetween" "leftMost" and "rightMost" to Data.SortedMap 2021-08-10 09:42:53 +01:00
Ellis Kesterton
0d6049cbcf
Fix error message for incorrect function patterns (#1816) 2021-08-09 10:00:34 +01:00
Edwin Brady
170af1e87a
Use Closures instead of NF in binders for normal forms (#1823)
* Skip forced arguments in conversion check

This isn't always safe - we have to have also checked the type of the
things we're converting - but in the place where it is safe it can be a
pretty significant saving.

* Use Closures, not NF, in Binders for normal forms

This means we don't need to reduce argument types during unification if
we don't need to. Also, we now try to avoid reducing closures during
unification if they are unified with a metavariable. Together, this
saves a huge amount of unnecessary evaluation in programs that do a lot
of compile time evaluation.

* Didn't mean to update idris2api.ipkg

* Fix dodgy merge
2021-08-08 17:05:29 +01:00
Zoe Stafford
1669fc351b
Refactor %builtin (#1803)
* Stub for future 'identity' optimisation
I plan to add this later, but I'm using for now for
NaturalToInteger and IntegerToNatural

* Refactor `%builtin`
fixes #1799

- automatically optimise all Natural shaped things
- NaturalToInteger and IntegerToNatural now use
  new `Identity` flag (internal use only for now)
  which signals the function is identity at runtime

* Use NaturalToInteger and IntegerToNatural for Nat and Fin
Also define show fin in terms of finToInteger, for speed

* Fix name handling for %builtin

* [ tests ] fixes + #1799

* remove %builtin from libs
Add back after next version

* Use resolved names where convenient
2021-08-03 14:19:17 +01:00
Zoe Stafford
8e1ca0eddf
Add break in each case alt in js backend (#1796)
* Add `break` in each case alt in js backend
Fixes #1795

* Remove some uneeded `break`s

* linter

* Follow @stefan-hoeck 's advice
This is neater
Note: I renamed breakAfterAssignment because it's too much work to type

* [ test ] Test for #1795

* cleanup: remove unneeded vcat
2021-07-30 07:16:23 +01:00
Sventimir
4920601fe9
Add tests for Nat ranges and fix bad range [1,2..1] behaviour. (#1794)
Co-authored-by: Marcin Pastudzki <marcin.pastudzki@gmail.com>
2021-07-28 06:52:59 +01:00
Mathew Polzin
b03395debe
Merge pull request #1603 from ska80/remove-realpath-notes
Remove all mentions of `realpath` from docs
2021-07-26 12:38:39 -07:00
Guillaume ALLAIS
13ef8ba707 [ fix #1782 ] remove the case-specific code
I can't make sense of this code, it seems to try to convert the
case function corresponding to `let (a, b) = f n in ...` into a
different case function where `f n` and `(a, b)` have been unified.
But if `f n` is a bona fide stuck computation, there's no chance of
this happening.

Just turning this off solves the #1782 and only breaks one function
in the whole of the idris2 repo (I would have expected our current
termination oracle to be too weak to detect it as valid anyway!)
and one in frex (which, again, should not have been seen as terminating).

Also fixes #1460
2021-07-26 17:03:16 +01:00
Guillaume ALLAIS
d0c0698c45 [ re #1771 ] Check parameters for positive uses
It's fine to allow positive occurences in (strictly positive)
parameters but we do need to check that these occurences are
strictly positive!
2021-07-23 13:30:24 +01:00
Guillaume ALLAIS
b24a9a51df [ re #1771 ] Fix another Erased-related issue (in nameIn) 2021-07-23 13:30:24 +01:00
Guillaume ALLAIS
230f42b697 [ re #1771 ] Do not use Erased to go under binders
In the `MkFix : f (Fix f) -> Fix f` example, using `Erased` for `f`
makes the type reduce to `[__] (Fix [__]) -> Fix [__]` and because
`[__] e1 ... en` computes to `[__]`, we end up with `[__] -> Fix [__]`
which does not reference `Fix` anymore.
2021-07-23 13:30:24 +01:00
André Videla
5389f8c2a8
Merge pull request #1770 from andrevidela/fix-if-then-else-interpolation
Fix #1767
2021-07-22 16:35:11 +00:00
Edwin Brady
e633a9fa6e Correct error018 test
I expect I got my local versions inconsistent while working on this...
2021-07-22 13:36:03 +01:00
Edwin Brady
edefd543f7 A bit of refactoring of argument elaboration order
In theory argument elaboration order doesn't matter, but in practice we
sometimes make choices for performance reasons, like helping with
disambiguation by knowing the target type.

This was kind of messy, now we can more clearly see what's going on.
Also, more importantly, it gives us a bit more control which we
sometimes need. For example, if we go choose to go right to left for
some performance heuristic it might turn out we don't have enough
information yet, in which case we need to delay and try again later.

Fixes #1743
2021-07-22 13:36:03 +01:00
André Videla
bab3897a9b move basic053->interpolation002, move basic061->basic053 2021-07-22 12:17:53 +00:00
André Videla
1276f47cf6 Fix #1767
The `if then else` syntax expects a block for the `then` and `else`
parts. Before this patch, the token `InterpEnd` was not a valid
follow up token to end a block. This adds `InterpEnd` as a closing
token for blocks, allowing `if then else` in interpolation slices
without additional parens.
2021-07-22 12:17:53 +00:00
André Videla
5576d30c27
Merge pull request #1736 from stepancheg/test-discovery
Implement test discovery
2021-07-22 08:56:02 +00:00
Edwin Brady
68db9fe0fe Add reg048 files
Odd, I thought I added these before, but it's probably because I got in
a mess with git and didn't re-add once I resolved that.
2021-07-19 00:21:28 +01:00
Edwin Brady
2068eb271b Better ordering of delayed elaborators
Instead of having an arbitrary looking priority number, record explicit
reasons for the delay, which helps order them sensibly when rerunning
them. Mostly this allows us to choose which ones to rerun, where it
helps, and helps order things to get better error messages.
2021-07-19 00:21:28 +01:00
Stiopa Koltsov
7325002dec Implement test discovery
`testInDir dir ...` lists all directories in `dir` which contains
`run` files, and such directories are considered tests.

This is done to make test addition/maintenance cheaper.

Convert some test directories to `testInDir`, but not all of them
because
* some directories are listed in several test groups
* other directories are have some tests disabled
2021-07-17 16:53:43 +01:00
Stiopa Koltsov
4eff6ac916 System.Directory.listDir
This function is what users want 99.9% of time.
2021-07-17 14:58:57 +01:00
Stiopa Koltsov
c7629e20fe Skip dot and dot-dot in nextDirEntry
These entries returned by `readdir` are legacy of Unix API, we don't
really need them. Most APIs do not return them (for example Java
`Files.newDirectoryStream` or Python `os.listdir`).
2021-07-17 14:58:28 +01:00
Stiopa Koltsov
0ecf74e434 System.Directory.nextDirEntry
* add `nextDirEntry` which returns `Maybe String`, so `Nothing` on
  the end of directory unlike `dirEntry` which returns unspecified error
  on the end of directory
* `dirEntry` is deprecated now, but not removed because compiler depends on it
* native implementation of `dirEntry` is patched to explicitly reset `errno`
  before the `readdir` call: without it end of directory and error were
  indistinguishable
* test added
2021-07-17 14:57:27 +01:00
Stepan Koltsov
ce44d3b50a
Change semantics of lines and unlines function to match Haskell and other languages (#1585)
* Add trailing newline on non-empty list in unlines

There are several reasons to do that:
* a line in a text file is something which ends with newline,
  and the last line is not special
* `unlines []` should be different from `unlines [""]`
* `unlines (a ++ b) = unlines a ++ unlines b`
* Haskell does it

* Change lines function behaviour
2021-07-17 14:54:23 +01:00
Ruslan Feizerakhmanov
ee063a5412
Apply "qualified do" notation to bangs and comprehensions (#1700)
* Propagate 'do qualification' to inner bangs and comprehensions

* Minor

* Remove banner in test

* Move tests from reg045 to reg047

* Move mbNS from Desugar.idr to Name.idr, renaming it to mbApplyNS
2021-07-17 14:52:22 +01:00
Kamil Shakirov
c4b41ee1ff Remove all mentions of realpath from docs
`realpath` is no longer needed to run executables.
2021-07-16 21:20:11 +06:00
Stiopa Koltsov
c4ed1395d9 Replace per signal counter with per signal flag
Operating system counter stores signals as flag set without counter.
So sending two signals to a process may result to one or two signal
handler invocation. Queueing signals inside Idris could give users
false sense of signals being are queue, while they are not.

In particular, test for signal could not work reliably for that
reason.

Also, practically we usually don't need have more than once signal
event.

This is follow-up to #1660. CC @mattpolzin
2021-07-16 11:31:53 +01:00
Giuseppe Lomurno
37c700907e Removed leak of internal names from test reflection010 2021-07-16 04:28:58 +02:00
Giuseppe Lomurno
07c62e9eef Fixed wrong reflection of records and parameters 2021-07-16 04:28:52 +02:00
Edwin Brady
f4cc2f1ea8
Merge pull request #1721 from edwinb/AliasQli-master
Updated: add doublePow to primitives
2021-07-15 23:17:53 +01:00
Stiopa Koltsov
c80a502627 Return Bool from IOArray.writeArray
As suggested in #1677.

Crashing on out-of-bounds might be more practical, but we can
reconsider it later.
2021-07-15 22:16:22 +01:00
Edwin Brady
f51aa22046 Bring #1719 up to date with latest changes 2021-07-15 22:04:49 +01:00
Edwin Brady
50c0116780
Merge pull request #1718 from edwinb/Russoul-unification
Postpone when instantiating if type is unknown
2021-07-15 21:16:00 +01:00
André Videla
e45d792283
Merge pull request #1701 from mattpolzin/alternative-errors
Show error output from multiple alternative parsing branches.
2021-07-15 20:06:25 +00:00
Edwin Brady
a709f6d369 Fix/reorganise tests 2021-07-15 20:24:40 +01:00
Edwin Brady
d9a56c5fd1 Merge branch 'unification' of https://github.com/Russoul/Idris2 into Russoul-unification 2021-07-15 20:24:27 +01:00
Mathew Polzin
948a5ba9df noticed I was not _quite_ retaining existing behavior around Alt error processing so fixed that. updated tests. 2021-07-15 12:05:23 -07:00
Edwin Brady
b192be32b8 Merge branch 'name-quote-single-brace' of https://github.com/buzden/Idris2 into buzden-name-quote-single-brace 2021-07-15 17:57:41 +01:00
Edwin Brady
b8082f4ed7
Merge pull request #1714 from edwinb/lodi-thread-data
fix arity for blodwen-set-thread-data
2021-07-15 16:21:31 +01:00
Edwin Brady
62586627d8 fix arity for blodwen-set-thread-data
This is an update of PR #540, thanks to @lodi
2021-07-15 15:02:43 +01:00
Mathew Polzin
289f1cc954 merge w/ upstream. 2021-07-15 06:29:56 -07:00
Edwin Brady
86aaed5ae1
Merge branch 'master' into fix-unquote-thing 2021-07-15 14:13:25 +01:00
Edwin Brady
35f23ac1d6
Merge pull request #1712 from edwinb/MarcelineVQ-elab-name-changes
Add more name reflections
2021-07-15 14:08:31 +01:00
Edwin Brady
9b0ebcd08b Merge branch 'elab-name-changes' of https://github.com/MarcelineVQ/Idris2 into MarcelineVQ-elab-name-changes 2021-07-15 13:16:47 +01:00
Guillaume ALLAIS
efcf44e8ba [ cosmetic ] use the whole range when underlining the problem 2021-07-15 07:32:43 +01:00
Mathew Polzin
221dadeb20 set default alt error count to 1 and create a config option that sets it to any number. 2021-07-14 20:23:29 -07:00
Mathew Polzin
1f21e787b1 Use commit to reduce the alternative parsing space as soon as an opening paren is encountered. 2021-07-14 17:22:40 -07:00
Edwin Brady
8cd265cf47
Merge pull request #1698 from stepancheg/move-rm-rf-build
Move rm -rf to the beginning of the test
2021-07-14 16:00:46 +01:00