summary refs log tree commit diff stats
path: root/compiler/sigmatch.nim
Commit message (Collapse)AuthorAgeFilesLines
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-2/+4
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* Make `typeRel` behave to spec (#22261)Ryan McConnell2023-09-301-15/+60
| | | | | | | | | | | | | | | | | | | | | | | | The goal of this PR is to make `typeRel` accurate to it's definition for generics: ``` # 3) When used with two type classes, it will check whether the types # matching the first type class (aOrig) are a strict subset of the types matching # the other (f). This allows us to compare the signatures of generic procs in # order to give preferrence to the most specific one: ``` I don't want this PR to break any code, and I want to preserve all of Nims current behaviors. I think that making this more accurate will help serve as ground work for the future. It may not be possible to not break anything but this is my attempt. So that it is understood, this code was part of another PR (#22143) but that problem statement only needed this change by extension. It's more organized to split two problems into two PRs and this issue, being non-breaking, should be a more immediate improvement. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #10542; suppresses varargs conversion warnings (#22757)ringabout2023-09-261-1/+1
| | | | fixes #10542 revives and close #20169
* Fix #21742: Check generic alias depth before skip (#22443)SirOlaf2023-09-081-2/+6
| | | | | | | | | | | | | | | Close #21742 Checking if there's any side-effects and if just changing typeRel is adequate for this issue before trying to look into related ones. `skipBoth` is also not that great, it can lead to code that works sometimes but fails when the proc is instantiated with branching aliases. This is mostly an issue with error clarity though. --------- Co-authored-by: SirOlaf <unknown> Co-authored-by: SirOlaf <>
* fully revert generic inst sym change, test #22646 (#22653)metagn2023-09-061-10/+2
| | | | | | | reverts #22642, reopens #22639, closes #22646, refs #22650, refs https://github.com/alaviss/union/issues/51, refs #22652 The fallout is too much from #22642, we can come back to it if we can account for all the affected code.
* fix sym of created generic instantiation type (#22642)metagn2023-09-051-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #22639 A `tyGenericInst` has its last son as the instantiated body of the original generic type. However this type keeps its original `sym` field from the original generic types, which means the sym's type is uninstantiated. This causes problems in the implementation of `getType`, where it uses the `sym` fields of types to represent them in AST, the relevant example for the issue being [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L191) called from [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L143). To fix this, create a new symbol from the original symbol for the instantiated body during the creation of `tyGenericInst`s with the appropriate type. Normally `replaceTypeVarsS` would be used for this, but here it seems to cause some recursion issue (immediately gives an error like "cannot instantiate HSlice[T, U]"), so we directly set the symbol's type to the instantiated type. Avoiding recursion means we also cannot use `replaceTypeVarsN` for the symbol AST, and the symbol not having any AST crashes the implementation of `getType` again [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L167), so the symbol AST is set to the original generic type AST for now which is what it was before anyway. Not sure about this because not sure why the recursion issue is happening, putting it at the end of the proc doesn't help either. Also not sure if the `cl.owner != nil and s.owner != cl.owner` condition from `replaceTypeVarsS` is relevant here. This might also break some code if it depended on the original generic type symbol being given.
* `initCandidate` and friends now return values (#22570)ringabout2023-08-281-36/+27
| | | | | | | | | * `initCandidate` and friends now return values * fixes semexprs.nim * fixes semcall.nim * Update compiler/semcall.nim
* Markdown code blocks migration part 9 (#22506)Amjad Ben Hedhili2023-08-191-1/+1
| | | | | * Markdown code blocks migration part 9 * fix [skip ci]
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-10/+9
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-2/+2
|
* Fix #5780 (#22428)Bung2023-08-091-1/+1
| | | * fix #5780
* fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generi… ↵Bung2023-08-081-2/+6
| | | | | (#20683) * fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generic proc is compile error
* use strictdefs for compiler (#22365)ringabout2023-08-061-6/+19
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fix #20883 Unspecified generic on default value segfaults the compiler (#21172)Bung2023-08-041-0/+5
| | | | | | | | | * fix #20883 Unspecified generic on default value segfaults the compiler * fallback to isGeneric * change to closer error * Update t20883.nim
* Fix crash when using uninstantiated generic (#22379)Jake Leahy2023-08-041-0/+2
| | | | | | | * Add test case * Add in a bounds check when accessing generic types Removes idnex out of bounds exception when comparing a generic that isn't fully instantiated
* Expands codegenDecl to work in function params. fixes #22306 (#22307)Juan M Gómez2023-07-231-1/+1
| | | | | | | * Expands codegenDecl to work in function params. fixes #22306 * makes the test more concrete so T{lit} params dont match * adds sfCodegenDecl
* fixes #22138 (#22221)Andreas Rumpf2023-07-041-2/+7
|
* fix nested call regression in generic bodies (#22189)metagn2023-06-291-0/+11
| | | fixes #22187
* make `var object` match better than `object` (#22152)metagn2023-06-251-1/+3
| | | | | | | | | | | * fix `var object` not matching better than `object` fixes #13302 * remove comment for brevity * try note * try minimize breaks
* fixes #22049; fixes #22054; implicit conversion keeps varness (#22097)ringabout2023-06-161-1/+7
| | | | | | | | | | | | | | | | | | | | | * fixes #22054; codegen for var tuples conv * rethink fixes * add test cases * templates only * fixes var tuples * keep varness no matter what * fixes typ.isNil * make it work for generics * restore isSubrange * add a test case as requested
* fix calls in generic bodies, delay typecheck when no overloads match (#22029)metagn2023-06-131-1/+7
| | | | | | | | | | | | | | | | | | | | | | | * sacrifice "tgenericshardcases" for working statics * legacy switch for CI, maybe experimental later * convert to experimental * apparently untyped needs the experimental switch * try special case call semcheck * try fix * fix compilation * final cleanup, not experimental, make `when` work * remove last needed use of untyped * fix unused warning in test * remove untyped feature
* clean up isNilConversion for seqs, strings (#22057)ringabout2023-06-091-7/+1
|
* make `proc` not implicitly convert to `pointer` with a preview define (#21953)metagn2023-05-301-1/+4
| | | | | | | | | * test `proc` not converting to `pointer` * ignore define for now to test * remove cstring * fixes, changelog
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-2/+2
| | | | | | | | | | | (#21667) * refactoring in preparation for better, simpler name mangling that works with IC flawlessly * use new disamb field * see if this makes tests green * make tests green again
* fix iterator equality + add test for proc equality + fix sameType (#21707)metagn2023-04-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * fix iterator equality + add test also for procs fixes #21706 * all targets * and isNil and repr * separate overloads, fix sameType * more restricted sameType? * merge overloads again?? * remove sametype change for now * fix sameType anyway (CI failure was not related) --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* actually fix #19015 (#21680)metagn2023-04-171-1/+3
| | | | | | | * actually fix #19015 * more tests * round out
* revert #21227 (#21681)metagn2023-04-171-6/+2
| | | | | | | | | * revert #21227 but keep test * add test for #21677 * don't export * delete test
* `proc` typeclass accounts for `iterator`, call conventions + `nil` fix + ↵metagn2023-04-111-5/+14
| | | | | | | | | | | | | document typeclass AST (#21629) * test fix #16546 #16548 + another issue * please don't tell me other packages do this * fix CI + test typeclass callconv pragma * better logic in parser * docs and changelog
* remove useVersion (#21626)metagn2023-04-081-1/+1
| | | test removing useVersion
* Use `analyseIfAddressTaken` logic for checking if address is taken in ↵Jake Leahy2023-03-201-2/+1
| | | | | | | | | | | | | | | | | | | converter (#21533) * Add a test case There are way more test cases (See all branches of analyseIfAddressTaken but this covers at least a second branch * Port analyseIfAddressTaken from semexprs to sigmatch This was done since we cannot import sem or semexprs (circular import) but we need the rest of the logic. In needs to be done here since the converter isn't semmed afterwards and so we can't just leave the process til later use the version from semexprs * Less hacky solution which has the checking be done in analyseIfAddressTakenInCall This was done instead of the recommendation on removing it since sfAddrTaken is used in places other than the backend * Remove weird whitespace * Still check nkHiddenAddr if we are checking a converter
* remove nosinks hacks from compiler (#21469)ringabout2023-03-041-1/+1
|
* Specify that address is taken when converter takes a var parameter (#21391)Jake Leahy2023-02-211-0/+1
| | | | | | | * Add test case * closes #21247 Add the sfAddrTaken flag to var parameters in converters This allows the JS backend to properly pass the parameter as a fat pointer
* fix typeRel of typeDesc (#21227)Bung2023-01-091-2/+6
|
* less verbose type mismatch messages (#21191)ringabout2022-12-281-17/+23
| | | | | | | | | * less verbose type mismatch messages * Update compiler/types.nim * fixes i386 * fixes i386
* Fix nimsuggest not suggesting fields in when theres static parameters (#21189)Jake Leahy2022-12-281-1/+1
| | | | | Don't check against empty arguments Add test case
* remove legacy code (#21134)ringabout2022-12-261-2/+0
| | | | | * remove legacy code * fixes
* fix #16541 (#21148)Bung2022-12-221-0/+2
|
* definite assignment analysis for let (#21024)ringabout2022-12-061-2/+5
| | | | | | | | | | | | | | | | | | | * draft for let daa * patch * fixes bugs * errors for global let variable reassignments * checkpoint * out param accepts let * add more tests * add documentation * merge tests
* deprecate `do:` meaning `do ():` + misc cleanup (#20927)metagn2022-12-061-0/+2
| | | | | | | | | | | | | | | | | * test disable do: block lambda lifting * fix last test [skip ci] * deprecate `do:` meaning `do ():` + misc cleanup closes https://github.com/nim-lang/RFCs/issues/486 * oops * fix * no idea what could be causing nimsuggest failure other than this * ensure ci works
* fix #20829 Regression in int64 type matching since (#21019)Bung2022-12-061-2/+4
| | | fix #20829 Regression in int64 type matching
* Revert "fixes #20883; Unspecified generic on default value segfaults the ↵ringabout2022-12-061-2/+1
| | | | | | | compiler" (#21028) Revert "fixes #20883; Unspecified generic on default value segfaults the compiler (#20917)" This reverts commit 10b6e4f5b4a119a8fa42f82a24ae7e4b08b2c103.
* fixes #20883; Unspecified generic on default value segfaults the compiler ↵ringabout2022-12-011-1/+2
| | | | | (#20917) test CI
* tyInt tyUint fit target int bit width (#20829)Bung2022-12-011-19/+28
|
* fix #13790; ptr char (+friends) should not implicitly convert to cstring ↵ringabout2022-11-241-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#20761) * fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* fix #19149 Invalid codegen when returning var tuple from a template (#20762)Bung2022-11-061-2/+3
| | | | | * fix #19149 Invalid codegen when returning var tuple from a template * fix type
* fix #19700 Crash when passing a template to a generic functio… (#20567)Bung2022-10-151-0/+2
| | | fix nim-lang#19700 Crash when passing a template to a generic function expecting a procedure
* fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural' (#20522)Bung2022-10-111-2/+1
| | | | | * fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural' * try fix
* DAA and 'out' parameters (#20506)Andreas Rumpf2022-10-061-8/+19
| | | | | | | | | | | * DAA and 'out' parameters * progress * documented strictDefs and out parameters * docs, tests and a bugfix * fixes silly regression
* Markdown code blocks part 6 (#20292)Andrey Makarov2022-08-311-3/+2
|
* remove a special case in sigmatch; distinct pointer types no longer match ↵ringabout2022-08-231-2/+0
| | | | | | | | | | | | | | | | `nil` type (#20251) * remove a special case in sigmatch; distinct pointer types no longer match `nil` type * add tests * fixes tests * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>