Amjad Ben Hedhili
8f7aedb3d1
Add hasDefaultValue type trait ( #22636 )
...
Needed for #21842 .
2023-09-04 23:18:58 +02:00
ringabout
d13aab50cf
fixes branches interacting with break, raise etc. in strictdefs ( #22627 )
...
```nim
{.experimental: "strictdefs".}
type Test = object
id: int
proc test(): Test =
if true:
return Test()
else:
return
echo test()
```
I will tackle https://github.com/nim-lang/Nim/issues/16735 and #21615 in
the following PR.
The old code just premises that in branches ended with returns, raise
statements etc. , all variables including the result variable are
initialized for that branch. It's true for noreturn statements. But it
is false for the result variable in a branch tailing with a return
statement, in which the result variable is not initialized. The solution
is not perfect for usages below branch statements with the result
variable uninitialized, but it should suffice for now, which gives a
proper warning.
It also fixes
```nim
{.experimental: "strictdefs".}
type Test = object
id: int
proc foo {.noreturn.} = discard
proc test9(x: bool): Test =
if x:
foo()
else:
foo()
```
which gives a warning, but shouldn't
2023-09-04 14:36:45 +02:00
metagn
480e98c479
resolve unambiguous enum symchoices from local scope, error on rest ( #22606 )
...
fixes #22598 , properly fixes #21887 and fixes test case issue number
When an enum field sym choice has to choose a type, check if its name is
ambiguous in the local scope, then check if the first symbol found in
the local scope is the first symbol in the sym choice. If so, choose
that symbol. Otherwise, give an ambiguous identifier error.
The dependence on the local scope implies this will always give
ambiguity errors for unpicked enum symchoices from generics and
templates and macros from other scopes. We can change `not
isAmbiguous(...) and foundSym == first` to `not (isAmbiguous(...) and
foundSym == first)` to make it so they never give ambiguity errors, and
always pick the first symbol in the symchoice. I can do this if this is
preferred, but no code from CI seems affected.
2023-09-03 13:59:03 +02:00
SirOlaf
d2f36c071b
Exclude block from endsInNoReturn, fix regression ( #22632 )
...
Co-authored-by: SirOlaf <>
2023-09-02 20:42:40 +02:00
metagn
bd6adbcc9d
fix isNil folding for compile time closures ( #22574 )
...
fixes #20543
2023-09-02 10:32:46 +02:00
Pylgos
9f1fe8a2da
Fix the problem where instances of generic objects with sendable pragmas are not being cached ( #22622 )
...
remove `tfSendable` from `eqTypeFlags`
2023-09-02 06:00:26 +02:00
metagn
2542dc09c8
use dummy dest for void branches to fix noreturn in VM ( #22617 )
...
fixes #22216
2023-09-01 15:38:25 +02:00
metagn
6738f44af3
unify explicit generic param semchecking in calls ( #22618 )
...
fixes #9040
2023-09-01 15:37:16 +02:00
Juan M Gómez
0c6e13806d
fixes internal error: no generic body fixes #1500 ( #22580 )
...
* fixes internal error: no generic body fixes #1500
* adds guard
* adds guard
* removes unnecessary test
* refactor: extracts containsGenericInvocationWithForward
2023-09-01 13:42:47 +02:00
metagn
f1789cc465
resolve local symbols in generic type call RHS ( #22610 )
...
resolve local symbols in generic type call
fixes #14509
2023-09-01 09:00:15 +02:00
metagn
53d9fb259f
don't update const symbol on const section re-sems ( #22609 )
...
fixes #19849
2023-09-01 08:59:48 +02:00
ringabout
affd3f7858
fixes #22613 ; Default value does not work with object's discriminator ( #22614 )
...
* fixes #22613 ; Default value does not work with object's discriminator
fixes #22613
* merge branches
* add a test case
* fixes status
* remove outdated comments
* move collectBranchFields into the global scope
2023-09-01 08:55:19 +02:00
SirOlaf
3b206ed988
Fix #22604 : Make endsInNoReturn traverse the tree ( #22612 )
...
* Rewrite endsInNoReturn
* Handle `try` stmt again and add tests
* Fix unreachable code warning
* Remove unreachable code in semexprs again
* Check `it.len` before skip
* Move import of assertions
---------
Co-authored-by: SirOlaf <>
2023-09-01 06:41:39 +02:00
metagn
ba158d73dc
type annotations for variable tuple unpacking, better error messages ( #22611 )
...
* type annotations for variable tuple unpacking, better error messages
closes #17989 , closes https://github.com/nim-lang/RFCs/issues/339
* update grammar
* fix test
2023-09-01 06:26:53 +02:00
ringabout
5bd1afc3f9
fixes #17197 ; fixes #22560 ; fixes the dest of newSeqOfCap in refc ( #22594 )
2023-08-31 19:04:32 +08:00
metagn
2e4e2f8f50
handle typedesc params in VM ( #22581 )
...
* handle typedesc params in VM
fixes #15760
* add test
* fix getType(typedesc) test
2023-08-30 07:23:14 +02:00
Juan M Gómez
d7634c1bd4
fixes an issue where sometimes wasMoved produced bad codegen for cpp ( #22587 )
2023-08-30 07:22:36 +02:00
metagn
b6cea7b599
clearer error for different size int/float cast in VM ( #22582 )
...
refs #16547
2023-08-29 14:59:49 +02:00
ringabout
d8ffc6a75e
minor style changes in the compiler ( #22584 )
...
* minor style changes in the compiler
* use raiseAssert
2023-08-29 13:59:51 +08:00
metagn
6b955ac4af
properly fold constants for dynlib pragma ( #22575 )
...
fixes #12929
2023-08-28 21:41:18 +02:00
metagn
3de8d75513
correct logic for qualified symbol in templates ( #22577 )
...
* correct logic for qualified symbol in templates
fixes #19865
* add test
2023-08-28 21:40:46 +02:00
ringabout
306b9aca48
initCandidate and friends now return values (#22570 )
...
* `initCandidate` and friends now return values
* fixes semexprs.nim
* fixes semcall.nim
* Update compiler/semcall.nim
2023-08-28 15:57:24 +08:00
Bung
0b78b7f595
fix #22548;environment misses for type reference in iterator access n… ( #22559 )
...
* fix #22548;environment misses for type reference in iterator access nested in closure
* fix #21737
* Update lambdalifting.nim
* remove containsCallKinds
* simplify
2023-08-27 14:29:24 +02:00
Juan Carlos
a108a451c5
Improve compiler cli args ( #22509 )
...
* .
* Fix cli args out of range with descriptive error instead of crash
* https://github.com/nim-lang/Nim/pull/22509#issuecomment-1692259451
2023-08-25 22:55:17 +02:00
metagn
1cc4d3f622
fix generic param substitution in templates ( #22535 )
...
* fix generic param substitution in templates
fixes #13527 , fixes #17240 , fixes #6340 , fixes #20033 , fixes #19576 , fixes #19076
* fix bare except in test, test updated packages in CI
2023-08-25 21:08:47 +02:00
ringabout
d677ed31e5
follow up #22549 ( #22551 )
2023-08-25 06:48:08 +02:00
ringabout
1013378854
fixes a strictdef ten years long vintage bug, which counts the same thing twice ( #22549 )
...
fixes a strictdef ten years long vintage bug
2023-08-24 20:56:58 +02:00
metagn
53d43e9671
round out tuple unpacking assignment, support underscores ( #22537 )
...
* round out tuple unpacking assignment, support underscores
fixes #18710
* fix test messages
* use discard instead of continue
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
---------
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
2023-08-24 06:11:48 +02:00
metagn
4f891aa50c
don't render underscore identifiers with id ( #22538 )
2023-08-23 13:43:02 +02:00
SirOlaf
3de75ffc02
Fix #21532 : Check if template return is untyped ( #22517 )
...
* Don't ignore return in semTemplateDef
* Add test
---------
Co-authored-by: SirOlaf <>
2023-08-23 06:18:35 +02:00
metagn
602f537eb2
allow non-pragma special words as user pragmas ( #22526 )
...
allow non-pragma special words as macro pragmas
fixes #22525
2023-08-21 20:08:57 +02:00
metagn
942f846f04
fix getNullValue for cstring in VM, make other VM code aware of nil cstring ( #22527 )
...
* fix getNullValue for cstring in VM
fixes #22524
* very ugly fixes, but fix #15730
* nil cstring len works, more test lines
* fix high
2023-08-21 20:08:00 +02:00
metagn
a4781dc4bc
use old typeinfo generation for hot code reloading ( #22518 )
...
* use old typeinfo generation for hot code reloading
* at least test hello world compilation on orc
2023-08-20 06:30:36 +02:00
SirOlaf
c0ecdb01a9
Fix #21722 ( #22512 )
...
* Keep return in mind for sink
* Keep track of return using bool instead of mode
* Update compiler/injectdestructors.nim
* Add back IsReturn
---------
Co-authored-by: SirOlaf <>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
2023-08-19 21:04:25 +02:00
Amjad Ben Hedhili
d77ada5bdf
Markdown code blocks migration part 9 ( #22506 )
...
* Markdown code blocks migration part 9
* fix [skip ci]
2023-08-19 15:14:56 +02:00
Juan Carlos
c44c8ddb44
Remove Deprecated Babel ( #22507 )
2023-08-19 07:05:06 +02:00
Alberto Torres
20cbdc2741
Fix #22366 by making nimlf_/nimln_ part of the same line ( #22503 )
...
Fix #22366 by making nimlf_/nimln_ part of the same line so the debugger doesn't advance to the next line before executing it
2023-08-18 21:13:27 +02:00
Tomohiro
eb83d20d0d
Add staticFileExists and staticDirExists ( #22278 )
2023-08-18 16:47:47 +02:00
ringabout
7fababd583
make float32 literals stringifying behave in JS the same as in C ( #22500 )
2023-08-17 18:52:38 +02:00
metagn
98c39e8e57
cascade tyFromExpr in type conversions in generic bodies ( #22499 )
...
fixes #22490 , fixes #22491 , adapts #22029 to type conversions
2023-08-17 18:52:28 +02:00
ringabout
940b1607b8
fixes #22357 ; don't sink elements of var tuple cursors ( #22486 )
2023-08-16 13:46:44 +02:00
Jason Beetham
6c4e7835bf
When in object handles procedure call again, fixes #22474 ( #22480 )
...
Ping @narimiran please backport to the 2.0 line.
2023-08-15 17:48:31 +02:00
ringabout
09d0fda7fd
fixes #22469 ; generates nimTestErrorFlag for top level statements ( #22472 )
...
fixes #22469 ; generates `nimTestErrorFlag` for top level statements
2023-08-14 13:08:01 +02:00
ringabout
4c89223171
relax the parameter of ensureMove; allow let statements ( #22466 )
...
* relax the parameter of `ensureMove`; allow let statements
* fixes the test
2023-08-12 13:23:54 +02:00
ringabout
23f3f9ae2c
better initialization patterns for seminst ( #22456 )
...
* better initialization patterns for seminst
* Update compiler/seminst.nim
* Update compiler/seminst.nim
2023-08-12 08:30:17 +08:00
Pylgos
48da472dd2
fix #22448 Remove structuredErrorHook temporary in tryConstExpr ( #22450 )
...
* fix #22448
* add test
2023-08-11 18:23:09 +02:00
ringabout
469c9cfab4
unpublic the sons field of PType; the precursor to PType refactorings ( #22446 )
...
* unpublic the sons field of PType
* tiny fixes
* fixes an omittance
* fixes IC
* fixes
2023-08-11 22:18:24 +08:00
ringabout
72bc72bf9e
refactor result = default(...) into object construction ( #22455 )
2023-08-11 22:16:58 +08:00
ringabout
9fed58d5a0
modernize lambdalifting ( #22449 )
...
* modernize lambdalifting
* follow @beef331's suggestions
2023-08-11 17:08:51 +08:00
ringabout
0bf286583a
initNodeTable and friends now return (#22444 )
2023-08-11 12:50:41 +08:00