summary refs log tree commit diff stats
path: root/tests/lookups
Commit message (Collapse)AuthorAgeFilesLines
* test case haul before 2.2 (#24119)metagn2024-09-176-0/+27
| | | | | closes #4774, closes #7385, closes #10019, closes #12405, closes #12732, closes #13270, closes #13799, closes #15247, closes #16128, closes #16175, closes #16774, closes #17527, closes #20880, closes #21346
* generate symchoice for ambiguous types in templates & generics + handle ↵metagn2024-08-255-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | types in symchoices (#23997) fixes #23898, supersedes #23966 and #23990 Since #20631 ambiguous type symbols in templates are rejected outright, now we generate a symchoice for type nodes if they're ambiguous, a generalization of what was done in #22375. This is done for generics as well. Symchoices also handle type symbols better now, ensuring their type is a `typedesc` type; this probably isn't necessary for everything to work but it makes the logic more robust. Similar to #23989, we have to prepare for the fact that ambiguous type symbols behave differently than normal type symbols and either error normally or relegate to other routine symbols if the symbol is being called. Generating a symchoice emulates this behavior, `semExpr` will find the type symbol first, but since the symchoice has other symbols, it will count as an ambiguous type symbol. I know it seems spammy to carry around an ambiguity flag everywhere, but in the future when we have something like #23104 we could just always generate a symchoice, and the symchoice itself would carry the info of whether the first symbol was ambiguous. But this could harm compiler performance/memory use, it might be better to generate it only when we have to, which in the case of type symbols is only when they're ambiguous.
* consider ambiguity for qualified symbols (#23989)metagn2024-08-203-0/+9
| | | | | | | | | | | | | fixes #23893 When type symbols are ambiguous, calls to them aren't allowed to be type conversions and only routine symbols are considered instead. But the compiler doesn't acknowledge that qualified symbols can be ambiguous, `qualifiedLookUp` directly tries to access the identifier from the module string table. Now it checks the relevant symbol iterators for any symbol after the first received symbol, in which case the symbol is considered ambiguous. `nkDotExpr` is also included in the whitelist of node kinds for ambiguous type symbols (not entirely sure why this exists, it's missing `nkAccQuoted` as well).
* adapt semOpAux to opt-in symchoices (#23750)metagn2024-06-251-0/+37
| | | | | | | | fixes #23749, refs #22716 `semIndirectOp` is used here because of the callback expressions, in this case `db.getProc(...)`, and `semIndirectOp` calls `semOpAux` to type its arguments before overloading starts. Hence it can opt in to symchoices since overloading will resolve them.
* ignore modules when looking up symbol with expected type (#23597)metagn2024-05-142-0/+19
| | | | | | | | | | | | | | | | fixes #23596 When importing a module and declaring an overloadable symbol with the same name as the module in the same scope, the module symbol can take over and make the declared overload impossible to access. Previously enum overloading had a quirk that bypassed this in a context where a specific enum type was expected but this was removed in #23588. Now this is bypassed in every place where a specific type is expected since module symbols don't have a type and so wouldn't be compatible anyway. But the issue still exists in places where no type is expected like `let x = modulename`. I don't see a way of fixing this without nerfing module symbols to the point where they're not accessible by default, which might break some macro code.
* remove bad type inference behavior for enum identifiers (#23588)metagn2024-05-101-0/+22
| | | | | | | | | | | | | | | refs https://github.com/nim-lang/Nim/issues/23586#issuecomment-2102113750 In #20091 a bad kind of type inference was mistakenly left in where if an identifier `abc` had an expected type of an enum type `Enum`, and `Enum` had a member called `abc`, the identifier would change to be that enum member. This causes bugs where a local symbol can have the same name as an enum member but have a different value. I had assumed this behavior was removed since but it wasn't, and CI seems to pass having it removed. A separate PR needs to be made for the 2.0 branch because these lines were moved around during a refactoring in #23123 which is not in 2.0.
* document the new ambiguous identifier resolution (#23166)metagn2024-01-113-0/+33
| | | | | refs #23123 Not sure if detailed enough.
* Fixes #23172 (#23173)Ryan McConnell2024-01-062-0/+15
| | | #23172
* ambiguous identifier resolution (#23123)metagn2024-01-013-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23002, fixes #22841, refs comments in #23097 When an identifier is ambiguous in scope (i.e. multiple imports contain symbols with the same name), attempt resolving it through type inference (by creating a symchoice). To do this efficiently, `qualifiedLookUp` had to be broken up so that `semExpr` can access the ambiguous candidates directly (now obtained directly via `lookUpCandidates`). This fixes the linked issues, but an example like: ```nim let on = 123 {.warning[ProveInit]: on.} ``` will still fail, since `on` is unambiguously the local `let` symbol here (this is also true for `proc on` but `proc` symbols generate symchoices anyway). Type symbols are not considered to not confuse the type inference. This includes the change in sigmatch, up to this point symchoices with nonoverloadable symbols could be created, they just wouldn't be considered during disambiguation. Now every proper symbol except types are considered in disambiguation, so the correct symbols must be picked during the creation of the symchoice node. I remember there being a violating case of this in the compiler, but this was very likely fixed by excluding type symbols as CI seems to have found no issues. The pure enum ambiguity test was disabled because ambiguous pure enums now behave like overloadable enums with this behavior, so we get a longer error message for `echo amb` like `type mismatch: got <MyEnum | OtherEnum> but expected T`
* Param match relax (#23033)Ryan McConnell2023-12-152-0/+15
| | | | | | | | | | | #23032 --------- Co-authored-by: Nikolay Nikolov <nickysn@gmail.com> Co-authored-by: Pylgos <43234674+Pylgos@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jason Beetham <beefers331@gmail.com>
* make expressions opt in to symchoices (#22716)metagn2023-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | refs #22605 Sym choice nodes are now only allowed to pass through semchecking if contexts ask for them to (with `efAllowSymChoice`). Otherwise they are resolved or treated as ambiguous. The contexts that can receive symchoices in this PR are: * Call operands and addresses and emulations of such, which will subject them to overload resolution which will resolve them or fail. * Type conversion operands only for routine symchoices for type disambiguation syntax (like `(proc (x: int): int)(foo)`), which will resolve them or fail. * Proc parameter default values both at the declaration and during generic instantiation, which undergo type narrowing and so will resolve them or fail. This means unless these contexts mess up sym choice nodes should never leave the semchecking stage. This serves as a blueprint for future improvements to intermediate symbol resolution. Some tangential changes are also in this PR: 1. The `AmbiguousEnum` hint is removed, it was always disabled by default and since #22606 it only started getting emitted after the symchoice was soundly resolved. 2. Proc setter syntax (`a.b = c` becoming `` `b=`(a, c) ``) used to fully type check the RHS before passing the transformed call node to proc overloading. Now it just passes the original node directly so proc overloading can deal with its typechecking.
* resolve unambiguous enum symchoices from local scope, error on rest (#22606)metagn2023-09-031-5/+2
| | | | | | | | | | | | | | | | 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.
* strictly typecheck expressions in bracketed `emit` (#22074)metagn2023-06-131-0/+12
| | | | | * strictly typecheck expressions in bracketed `emit` * use nim check in test
* retain forced open undeclared ident information (#22019)metagn2023-06-071-0/+17
|
* some test cleanups & category reorganization (#22010)metagn2023-06-0616-0/+309
| | | | | | | | | | | | | | | | | * clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
* new .redefine pragma for templates, warn on redefinition without it (#20211)metagn2022-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test CI for template redefinitions * adapt asyncmacro * fix quote * fix again * try something else * revert * fix ioselectors_select, disable packages CI * adapt more tests & simplify * more * more * more * rename to redefine, warn on implicit redefinition * basic documentation [skip ci] * Update compiler/lineinfos.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* make megatest consistent with unjoined tests wrt newlines, honor newlines in ↵Timothee Cour2020-11-281-1/+1
| | | | | | | output spec (#16151) * fix megatest newlines * still allow missing trailing newline for now but in a more strict way than before
* implement the 'bind' statement for generics, it was an oversight that this ↵Andreas Rumpf2020-06-071-0/+17
| | | | was never implemented (#14584)
* Allow void macro result (#11286)Arne Döring2019-05-211-1/+1
| | | | | * allow void macro result * add test for void macro result type
* updated tests to be executedArne Döring2018-11-231-1/+7
|
* delete old cruftArne Döring2018-11-231-4/+0
|
* fixes #4353Andreas Rumpf2016-08-041-0/+4
|
* fixes #4555Andreas Rumpf2016-08-021-0/+17
|
* tests: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-042-3/+3
| | | | via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
* make tests greenAraq2014-08-311-1/+1
|
* Changed tests and tools to use 'discard' statements instead of 'nil' for ↵Clay Sweetser2014-02-151-7/+7
| | | | empty blocks.
* tester support html generationAraq2014-01-141-0/+29
|
* new tester; all tests categorizedAraq2014-01-131-0/+17