Commit Graph

57 Commits

Author SHA1 Message Date
flywind
7bfb9f0002 close #17636 (#17643) 2021-04-06 16:20:01 +02:00
ee7
14c61ecf24 strictFuncs+views: add test that imports stdlib modules (#16878)
This commit attempts to improve testing of strictFuncs and views, and
prevent regressions like #16873 (resolved by 0b01eddace).

We previously only explicitly tested strictFuncs and views with a
smaller number of stdlib modules, mostly in:
- tests/effects/tstrict_funcs.nim
- tests/views/tcan_compile_nim.nim

Note that this commit leaves the `pegs` module commented out; it
cannot currently be compiled with `--experimental:views` (see #16892).

Note also that this commit is not sufficient to test strictFuncs and
views, but it does detect a subset of problems.
2021-02-03 16:00:29 +01:00
ee7
0b01eddace critbits: fix error from strictFuncs (#16877)
Previously, compiling a file containing just `import critbits` with
`nim c --experimental:strictFuncs` would produce the following error:
    critbits.nim(529, 6) Error: 'toCritBitTree' can have side effects

This was introduced by 2aed418698 (#16564).

Fixes: #16873
2021-02-01 13:14:23 +01:00
Timothee Cour
8f62cd512c fix manual to reflect reality for .nosideeffect (#16781) 2021-01-22 20:04:48 +01:00
ee7
87e634aab3 rationals.nim: Use func everywhere (#16302) 2020-12-09 16:17:50 +01:00
ee7
6f57ebae34 sequtils.nim: Use func (#16293)
* sequtils.nim: proc -> func

* sequtils.nim: proc -> func in links

* sequtils.nim: proc -> func in non-link doc comments

* test: add `sequtils` to strictFuncs test
2020-12-09 12:11:16 +01:00
ee7
140ebe6019 complex.nim: Use func everywhere (#16294) 2020-12-09 10:57:12 +01:00
ee7
2297b96238 math.nim: Use func everywhere (#16285)
* math.nim: procs with {.noSideEffect} -> funcs

* math.nim: procs without {.noSideEffect.} -> funcs

* math.nim: proc -> func in links

* math.nim: proc -> func in doc comments

* test: add `math` to strictFuncs test
2020-12-07 23:26:14 +01:00
ee7
84fea7c144 strutils.nim: Use func everywhere (#16281)
* strutils.nim: procs with {.noSideEffect.} -> func

* strutils.nim: procs without {.noSideEffect.} -> func

* strutils.nim: proc -> func for links

* strutils.nim: proc -> func in doc comments

* test: add strutils to strictFuncs test

* test: proc -> func in errmsg test
2020-12-07 17:07:12 +01:00
flywind
218ff27b70 fix #15851 (#15852)
* fix #15851

* {.cast(noSideEffect).}
2020-11-06 11:40:14 +01:00
cooldome
610e9b2fe9 fix #15756 (#15761)
* fix #15756

* simplify test
2020-10-28 13:24:38 +00:00
Andreas Rumpf
0426a4d85a fixes #15508 (#15509) 2020-10-07 14:38:25 +02:00
Paul Tan
fa84121421 effects: exclude swap() from "indirect calls" assumption (#15504)
swap() will never call any procs passed to it, and so it can be safely
excluded from the "assume indirect calls are taken" effects tracking
rule.
2020-10-06 18:05:31 +02:00
IDF
9560e49e8f New hint for unused exceptions in .raises (#15492)
* New hint for unused exceptions in .raises

* Fix effects test

* Further adapt teffects1.nim
2020-10-06 16:49:30 +02:00
Andreas Rumpf
92163fa330 implements https://github.com/nim-lang/RFCs/issues/258 (#15503)
* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
2020-10-06 16:47:15 +02:00
flywind
af9cc2882f use func in uri module (#15486) 2020-10-05 17:04:08 +02:00
Andreas Rumpf
ab405c936e views: yet another bugfix (#15447)
* views: yet another bugfix

* views: extended the spec

* views: take into account potential hidden mutations via proc calls
2020-10-01 15:04:36 +02:00
Andreas Rumpf
2b91845f1d refactoring, fixes yet another strictFuncs regression (#15446) 2020-10-01 11:16:04 +02:00
Andreas Rumpf
57b7841c18 better support for slices as views (#15414)
* moved view tests to tests/views
* refactoring
* more refactorings
* better support for system.toOpenArray for first class view types
2020-09-27 09:20:10 +02:00
Andreas Rumpf
9a110047cb testament improvement: allow inline error messages inside test cases (#15294)
* testament support for inline error messages
* adapt teffects1.nim test to show the potential
2020-09-10 16:30:20 +02:00
Andreas Rumpf
217675cf84 borrow checking refinements (#15290)
* added basic borrowing test
2020-09-09 14:19:22 +02:00
Andreas Rumpf
2f6d04fd5d strict funcs: use control flow information for a more precise analysis (#15271)
* strict funcs: use control flow information for a more precise analysis

* cursor inference uses control flow information
2020-09-06 22:01:39 +02:00
Andreas Rumpf
2aca748ddd strict func: much better error messages (#15068)
* strict func: much better error messages
* documented the 'strict funcs' mode
2020-07-25 19:36:53 +02:00
Andreas Rumpf
7ca32c86bb writing to a location counts as "side effect"; implements https://github.com/nim-lang/RFCs/issues/234 (#15030) 2020-07-25 15:14:28 +02:00
Andreas Rumpf
da29222f86 init checks and 'out' parameters (#14521)
* I don't care about observable stores
* enforce explicit initializations
* cleaner code for the stdlib
* stdlib: use explicit initializations
* make tests green
* algorithm.nim: set result explicitly
* remove out parameters and bring the PR into a mergable state
* updated the changelog
2020-06-23 10:53:57 +02:00
Andreas Rumpf
03c146cd93 do not track 'raise Defect' in the .raises: [] clause anymore (#14298)
* do not track 'raise Defect' in the .raises: [] clause anymore

* --panics:on maps 'raise Defect' to an unrecoverable fatal error

* make tests green again

* update the documentation too
2020-05-11 16:25:56 +02:00
Jacek Sieka
7d6cbf290a Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
2020-04-28 19:56:01 +02:00
Clyybber
eca8f1d79f Add tests for #8481, #6490 and #4061 (#14083) 2020-04-23 19:52:33 +02:00
Andreas Rumpf
2a278f6eba '.push raises: []' now also affects proc types (#13776)
* '.push raises: []' now also affects proc types

* fixes the regression

* less disruptive bugfix

* another attempt
2020-03-29 22:00:18 +02:00
Araq
ef2566218e better error messages for Nim's effect system 2020-03-22 20:45:03 +01:00
Andreas Rumpf
c86b1fbcac fixes a critical GC safety inference bug (#10615)
* fixes a critical GC safety inference bug
* make nimsuggest compile again
* make Nimble compile again
2019-03-05 19:54:44 +01:00
Andreas Rumpf
f55d094cf2 fixes #6955 2019-02-13 23:30:14 +01:00
LemonBoy
f23b0a7dc8 Fix handling of reraise in effect tracking (#10582)
This is the MVP in order not to get a completely useless error message
from the compiler.

Fixes #10579
2019-02-07 17:07:03 +01:00
Andreas Rumpf
0036014727 system refactorings (#10559)
* move IO subsystem into its own module; refs #10385
* make standalone test compile again
* make C++ examples compile again
* make more tests green
* make sysAssert and gcAssert work again
2019-02-06 21:00:00 +01:00
LemonBoy
3ce6b2acb9 Fix exception tracking in try blocks (#10455)
Exceptions raised inside a nkFinally/nkExcept block are not caught by
the block itself.

Fixes #3886
2019-01-27 10:32:44 +01:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Arne Döring
e012eb1001 updated tests to be executed 2018-11-23 11:58:28 +01:00
Andreas Rumpf
ae82406c8b make tests green again 2018-07-05 19:14:18 +02:00
Andreas Rumpf
0926754e68 make tests green again 2018-07-05 15:51:04 +02:00
Andreas Rumpf
74fe7a800b make tests green again 2018-05-02 13:34:54 +02:00
Araq
b57d14b1ae make more tests green 2018-02-10 20:55:22 +01:00
Andreas Rumpf
e6f0bff6dd make tests green again 2017-10-15 09:32:53 +02:00
Araq
9af9480340 fixes #5620 2017-10-14 22:35:20 +02:00
Andreas Rumpf
f1e4d8ed74 side-effect computation now done in the proper pass; fixes #4254 2016-08-25 16:33:51 +02:00
Adam Strzelecki
e80465dacf tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:04:32 +02:00
patrick dw
69e15ac32f renamed writeln to writeLine in tests 2015-06-19 01:34:34 -05:00
Araq
c8dbeaa09b make test green 2015-04-11 10:01:11 +02:00
def
546acfaf4e Clean up tests/effects 2015-02-04 21:20:01 +01:00
Araq
a4b2762249 fixes #325 2015-01-28 19:31:36 +01:00
Araq
c4d05ca130 better effect inference 2014-11-02 14:35:13 +01:00