-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strictFuncs+views: add test that imports stdlib modules #16878
Conversation
5bd71a6
to
7154e47
Compare
I have also been thinking about the state of several experimental features and how to improve their testing. Anyways, we do need to a way to improve testing and usage of experimental features. Lets see if anybody else has any good ideas. |
I believe these tests will show that something is wrong, but since the space over which something is wrong is rather large narrowing will take a lot of time. There is still a lot of utility here, so don't want to downplay the value. Personally, I think something that would not only help here but also compiler testing in general would be a code generator and property based testing. An example I can recall right now (though I'm sure there are others) is in a language called Alpaca (ML like language atop BEAM/Erlang), where they used Erlang and the propEr library, you can see the test code here. Good news is that we already have an RNG (Mersenne), the missing parts to get started are generators to manage the seed and invocation counts for runs, then it's generating strings, numbers, etc... but I'd recommend heading down this road. To help create examples of various combinations of experimental features. Hope that's the type of idea you were soliciting on IRC, @nc-x. |
7727eb6
to
65b24f7
Compare
Indeed: this PR isn't sufficient to test strictFuncs, but it does detect a subset of problems. This PR does not detect that compiling something like the below with import std/sequtils
type
Foo = ref object
x: int
let a = repeat(1, 3)
doAssert a == @[1, 1, 1] # works with `--experimental: strictFuncs`
let b = repeat(Foo(x: 2), 3) # error with `--experimental:strictFuncs` currently produces an error on devel:
See #16305 (the above example is similar to example 5). The implementation of Nim/lib/pure/collections/sequtils.nim Lines 171 to 182 in c05d1aa
|
This commit attempts to improve testing of strictFuncs and views, and prevent regressions like nim-lang#16873 (resolved by 0b01edd). 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 nim-lang#16892). Note also that this commit is not sufficient to test strictFuncs and views, but it does detect a subset of problems.
65b24f7
to
73df251
Compare
Ready for review. Questions for the reviewer (mostly bikeshedding):
If you have suggested changes to the testament use, please use the GitHub "suggested changes" UI or provide the full contents of the |
Good idea. We know that --gc:orc doesn't work yet but I know the other options were tested with bootstrapping. And we should ensure it stays this way, yes. |
It's ok this way. We can always change it later.
Action: "compile" is worse than testing things compile completely.
Look ok, we can always patch it later.
In "tests/strictfuncs" I guess but we can move them around later.
If there is such a way, it would hardly be better than your approach.
Maybe. Eventually. |
@ee7 this should use an auto-generated list of modules with a blacklist of unsupported modules instead of a whitelist, otherwise this becomes out of sync and is a maintenance hurdle. See how to do this in #13221 or (newer) https://github.com/nim-lang/fusion/pull/24/files |
This commit attempts to improve testing of strictFuncs and views, and prevent regressions like nim-lang#16873 (resolved by 0b01edd). 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 nim-lang#16892). Note also that this commit is not sufficient to test strictFuncs and views, but it does detect a subset of problems.
This commit attempts to improve testing of strictFuncs and views, and
prevent regressions like #16873 (resolved by 0b01edd).
We previously only explicitly tested strictFuncs and views with a
smaller number of stdlib modules, mostly in:
Nim/tests/effects/tstrict_funcs.nim
Lines 1 to 16 in 111092e
and in
Nim/tests/views/tcan_compile_nim.nim
Lines 1 to 4 in de4f260
Note that this commit leaves the
pegs
module commented out; itcannot currently be compiled with
--experimental:views
(see #16892).Note also that this PR is not sufficient to test strictFuncs and views,
but it does detect a subset of problems. One regression that it does not
detect is when compiling the below with
--experimental:strictFuncs
which compiles without error in Nim 1.4.2, but currently produces the
error
'repeat' can have side effects
in Nim devel.As far as I can tell, we didn't test
strictFuncs
andviews
with the stdlib much: