summary refs log tree commit diff stats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* fixes #23982; codegen regression passing pointer expressions to inline ↵ringabout2024-08-201-0/+11
| | | | | iterators (#23986) fixes #23982
* fixes #23973; fixes #23974; Memory corruption with lent and ORC (#23981)ringabout2024-08-201-0/+31
| | | | fixes #23973; fixes #23974
* allow `untyped` arguments to fail to compile in overload mismatch error (#23984)metagn2024-08-201-0/+37
| | | | | | | | | | | | | | | | fixes #8697, fixes #9620, fixes #23265 When matching a `template` with an `untyped` argument fails because of a mismatching typed argument, `presentFailedCandidates` tries to sem every single argument to show their types, but trying to type the `untyped` argument can fail if it's supposed to use an injected symbol, so we get an unrelated error message like "undeclared identifier". Instead we use `tryExpr` as the comment suggests, setting the type to `untyped` if it fails to compile. We could also maybe check if an `untyped` argument is expected in its place and not try to compile the expression if it is but this would require a bit of reorganizing the code here and IMO it's better to have the information of what type it would be if it can be typed.
* fix infinite recursion in term rewriting macros tests (#23979)metagn2024-08-202-3/+7
| | | Noticed Hint [Pattern] spam in CI
* make all generic aliases tyAlias (#23978)metagn2024-08-202-1/+9
| | | | | | | | | | | | | fixes #23977 The problem is that for *any* body of a generic declaration, [semstmts](https://github.com/nim-lang/Nim/blob/2e4d344b43b040a4dce2c478ca13e49979e491fc/compiler/semstmts.nim#L1610-L1611) sets the sym of its value to the generic type name, and [semtypes](https://github.com/nim-lang/Nim/blob/2e4d344b43b040a4dce2c478ca13e49979e491fc/compiler/semtypes.nim#L2143) just directly gives the referenced type *specifically* when the expression is a generic body. I'm blaming `semtypes` here because it's responsible for the type given but the exact opposite behavior specifically written in makes me think generating an alias type here maybe breaks something.
* Fixes #23962 `resetLoc`doenst produce any cgen code in `importcpp` types ↵Juan M Gómez2024-08-182-0/+49
| | | | (#23964)
* allow generic compileTime proc folding (#22022)metagn2024-08-181-0/+29
| | | | | | | | | | | | | | fixes #10753, fixes #22021, refs #19365 (was fixed by #22029, but more faithful test added) For whatever reason `compileTime` proc calls did not fold if the proc was generic ([since this folding was introduced](https://github.com/nim-lang/Nim/commit/c25ffbf2622a197c15a4a3bd790b1bc788db2c7f#diff-539da3a63df08fa987f1b0c67d26cdc690753843d110b6bf0805a685eeaffd40)). I'm guessing the intention was for *unresolved* generic procs to not fold, which is now the logic. Non-magic `compileTime` procs also now don't fold at compile time in `typeof` contexts to avoid possible runtime errors (only the important) and prevent double/needless evaluation.
* always lookup pure enum symbols if expected type is enum (#23976)metagn2024-08-171-0/+13
| | | | | | | | | | | | | | | | | | | | fixes #23689 Normally pure enum symbols only "exist" in lookup if nothing else with the same name is in scope. But if an expression is expected to be an enum type, we know that ambiguity can be resolved between different symbols based on their type, so we can include the normally inaccessible pure enum fields in the ambiguity resolution in the case that the expected enum type is actually a pure enum. This handles the use case in the issue of the type inference for enums reverted in #23588. I know pure enums are supposed to be on their way out so this might seem excessive, but the `pure` pragma can't be removed in the code in the issue due to a redefinition error, they have to be separated into different modules. Normal enums can still resolve the ambiguity here though. I always think about making a list of all the remaining use cases for pure enums and I always forget. Will close #23694 if CI passes
* fixes docgen regression: don't add newLine for code if it's the first line ↵ringabout2024-08-172-11/+6
| | | | | | | | | | | | | | | (#23154) Before (devel) ![image](https://github.com/nim-lang/Nim/assets/43030857/cde37109-027a-46c1-a37e-1d6062e6c609) After (this PR and stable) ![image](https://github.com/nim-lang/Nim/assets/43030857/3366877c-7223-4749-a584-fe93f731281f) It now keeps the same behavior as before
* fixes default float ranges (#23957)ringabout2024-08-161-0/+12
|
* fix `is` with `type`/`typedesc` crashing the compiler (#23967)metagn2024-08-161-0/+4
| | | | | | | | | | fixes #22850 The `is` operator checks the type of the left hand side, and if it's generic or if it's a `typedesc` type with no base type, it leaves it to be evaluated later. But `typedesc` types with no base type precisely describe the default typeclass `type`/`typeclass`, so this condition is removed. Maybe at some point this represented an unresolved generic type?
* remove nontoplevel type hack + consider symbol disamb in type hash (#23969)metagn2024-08-161-0/+9
| | | | | | | | | | | | | | fixes #22571 Removes the hack added in #13589 which made non-top-level object type symbols `gensym` because they couldn't be mangled into different names for codegen vs. top-level types. Now we consider the new `disamb` field (added in #21667) of the type symbols in the type hash (which is used for the mangled name) to differentiate between the types. In other parts of the compiler, specifically the [proc mangling](https://github.com/nim-lang/Nim/blob/298ada3412c9cf5971abc2b3b891b9bb8612e170/compiler/mangleutils.nim#L59), `itemId.item` is used instead of the `disamb` field, but I didn't use it in case it's the outdated method.
* fixes #23954; uint8 > 8 bit at compile-time (#23955)ringabout2024-08-151-0/+5
| | | fixes #23954
* supports `default` for range types using `firstOrd` with ↵ringabout2024-08-131-2/+16
| | | | | `nimPreviewRangeDefault` (#23950) ref https://github.com/nim-lang/Nim/issues/23943
* fixes #23947; .uint8 compile-time error (#23948)ringabout2024-08-131-0/+10
| | | fixes #23947
* Adds `SEQ_DECL_SIZE 1` back under `clang` and a test (#23942)Juan M Gómez2024-08-122-0/+11
|
* opensym as node kind + fixed experimental switch (#23892)metagn2024-08-124-0/+60
| | | | | | | | | | | | | | | refs https://github.com/nim-lang/Nim/pull/23873#discussion_r1687995060, fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in #23102 and #23873, into a node kind `nkOpenSym` that forms a unary node containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`.
* Implemented `compileOption` for `experimental` to test if a feature i… ↵Don-Duong Quach2024-08-122-0/+39
| | | | | | | | (#23933) …s enabled at compile time. #8644 This doesn't handle the case if `{.push experimental.}` is used, but at least we can test if a feature was enabled globally.
* fixes #23936; opcParseFloat accepts the wrong register as the first param ↵ringabout2024-08-121-0/+11
| | | | | | [backport] (#23941) fixes #23936 follow up https://github.com/nim-lang/Nim/pull/20527
* fixes jsbigint64 regression; keeps convs to `Number` in danger mode (#23926)ringabout2024-08-111-0/+17
| | | fixes jsbigint64 regression
* fixes #23932; vmopsDanger for os.getCurrentDir errors (#23934)ringabout2024-08-111-2/+5
| | | | fixes #23932 ref https://github.com/jmgomez/NimForUE/issues/36
* don't treat template/macro/module as overloaded for opensym (#23939)metagn2024-08-111-1/+1
| | | | | | | | | | | | | | actually fixes #23865 following up #23873 In the handling of `nkIdent` in `semExpr`, the compiler looks for the closest symbol with the name and [checks the symbol kind](https://github.com/nim-lang/Nim/blob/6126a0bf46f4e29a368b8baefea69a2bcae54e93/compiler/semexprs.nim#L3171) to also consider the overloads if the symbol kind is overloadable. But it treats the normally overloadable template/macro/module sym kinds the same as non-overloadable symbols, just calling `semSym` on it. We need to mirror this behavior in `semOpenSym`; we treat the captured symchoice as a fresh identifier, so if the symbol we find is a template/macro/module, we use that symbol immediately as opposed to waiting for overloads.
* fixes #14522 #22085 #12700 #23132; no range check for uints (#23930)ringabout2024-08-112-2/+27
| | | | | | | | | | fixes #14522 fixes #22085 fixes #12700 fixes #23132 closes https://github.com/nim-lang/Nim/pull/22343 (succeeded by this PR) completes https://github.com/nim-lang/RFCs/issues/175 follow up https://github.com/nim-lang/Nim/pull/12688
* fixes #23914; jsondoc broken in devel (#23916)ringabout2024-08-112-2/+7
| | | | | follows up https://github.com/nim-lang/Nim/pull/23064 fixes #23914
* fixes #23907; Double destroy using proc type alias with a sink (#23909)ringabout2024-08-111-0/+23
| | | fixes #23907
* fixes #23902; Compiler infers sink in return type from auto (#23904)ringabout2024-08-111-0/+8
| | | fixes #23902
* closes #6549; adds a test case (#23929)ringabout2024-08-091-1/+17
| | | closes #6549
* closes #21347; adds a test case (#23917)ringabout2024-08-041-0/+8
| | | closes #21347
* fixes #23894; succ/pred shouldn't raise OverflowDefect for unsigned integers ↵ringabout2024-07-261-0/+6
| | | | | | | (#23895) fixes #23894 keeps it consistent with `inc`
* implement genericsOpenSym for symchoices (#23873)metagn2024-07-253-1/+65
| | | | | | | | | | fixes #23865 The node flag `nfOpenSym` implemented in #23091 for sym nodes is now also implemented for open symchoices. This means the intended behavior is still achieved when multiple overloads are in scope to be captured, so the issue is fixed. The code for the flag is documented and moved into a helper proc and the experimental switch is now enabled for the compiler test suite.
* Overload resultion with generic variables an inheritance (#23870)Ryan McConnell2024-07-242-21/+84
| | | The test case diff is self explanatory
* fixes #19171; have `openArray` converted from `ptr UncheckedArray` be ↵Buldram2024-07-241-0/+19
| | | | | | mutable (#23882) Makes `toOpenArray(x: ptr UncheckedArray)` always return a `var openArray` regardless of if `x` is mutable.
* doc,test(times): followup #23861 (#23881)lit2024-07-231-1/+13
| | | followup #23861
* fixes #23869; sink generic typeclass (#23874)Ryan McConnell2024-07-221-0/+26
| | | | | | | Still have to look this over some. We'll see. I put sink in this branch simply because I saw `tyVar` there and for no other reason. In any case the problem appears to be coming from `liftParamType` as it removes the `sink` type from the formals. #23869
* Fix out-of-bounds slicing in std/varints (#23868)Buldram2024-07-221-1/+1
| | | | | | Corrects a slicing mistake in the `std/varints` implementation which caused it to fail when writing large numbers into buffers smaller than 10..13-bytes, now 9-byte buffers are sufficient as the documentation states.
* Merge tyUncheckedArray with tySeq in typeRel (#23866)SirOlaf2024-07-201-0/+2
| | | | | | Ref https://github.com/nim-lang/Nim/issues/23836#issuecomment-2233957324 Their types are basically equivalent so they should behave the same way for type relations.
* bypass constraints for tyFromExpr in generic bodies (#23863)metagn2024-07-201-0/+18
| | | | | | | | | | | | | | | | | | | | | | | fixes #19819, fixes #23339 Since #22029 `tyFromExpr` does not match anything in overloading, so generic bodies can know which call expressions to delay until the type can be evaluated. However generic type invocations also run overloading to check for generic constraints even in generic bodies. To prevent them from failing early from the overload not matching, pretend that `tyFromExpr` matches. This mirrors the behavior of the compiler in more basic cases like: ```nim type Foo[T: int] = object x: T Bar[T] = object y: Foo[T] ``` Unfortunately this case doesn't respect the constraint (#21181, some other bugs) but `tyFromExpr` should easily use the same principle when it does.
* fix generics treating symchoice symbols as uninstantiated (#23860)metagn2024-07-191-0/+91
| | | | | | | | | | | | | fixes #23853 Since #22610 generics turns the `Name` in the `GT.Name` expression in the test code into a sym choice. The problem is when the compiler tries to instantiate `GT.Name` it also instantiates the sym choice symbols. `Name` has type `template (E: type ExtensionField)` which contains the unresolved generic type `ExtensionField`, which the compiler mistakes as an uninstantiated node, when it's just part of the type of the template. The compilation of the node itself and hence overloading will handle the instantiation of the proc, so we avoid instantiating it in `semtypinst`, similar to how the first nodes of call nodes aren't instantiated.
* fixes #23858; 2.2.0 rc1 regression with cdecl functions (#23859)ringabout2024-07-181-0/+11
| | | | | | fixes #23858 We should not assign fields to fields for returns of function calls because calls might have side effects.
* Set type of object constructor during annotateType (#23852)SirOlaf2024-07-171-0/+23
| | | | | | Fix https://github.com/nim-lang/Nim/issues/23547 Tested locally with the included test, the test from constantine and the original issue.
* fixes #23837; cursor now processes distinct types with a destructor (#23845)ringabout2024-07-171-0/+51
| | | fixes #23837
* make routine implicitly gensym when other gensym symbol exists again (#23842)metagn2024-07-162-1/+13
| | | | | | | | | | | | | fixes #23813, partially reverts #23392 Before #23392, if a `gensym` symbol was defined before a proc with the same name in a template even with an `inject` annotation, the proc would be `gensym`. After #23392 the proc was instead changed to be `inject` as long as no `gensym` annotation was given. Now, to keep compatibility with the old behavior, the behavior is changed back to infer the proc as `gensym` when no `inject` annotation is given, however an explicit `inject` annotation will still inject the proc. This is also documented in the manual as the old behavior was undocumented and the new behavior is slightly different.
* fixes semi-regression; discard check now skips `nkHiddenSubConv` (#23840)ringabout2024-07-161-0/+9
| | | | | follow up https://github.com/nim-lang/Nim/pull/23681 ref https://forum.nim-lang.org/t/11987
* fixes regression; block can have arbitrary exit points; too hard for a ↵ringabout2024-07-161-0/+12
| | | | | | | | simple analysis (#23839) follow up https://github.com/nim-lang/Nim/pull/23681 ref https://forum.nim-lang.org/t/11987 ref https://github.com/nim-lang/Nim/issues/23836#issuecomment-2227267251
* fixes #23825; Busy wait on waitid, sleeping at regular intervals (#23826)Mark Leyva2024-07-121-1/+16
| | | | | | | | | Addresses #23825 by using the approaching described in https://github.com/nim-lang/Nim/pull/23743#issuecomment-2199523110. This takes the approach from Python's `subprocess` library which calls `waitid` in loop, while sleeping at regular intervals. CC @alex65536
* fixes 23823; array static overload - again (#23824)Ryan McConnell2024-07-111-0/+10
| | | #23823
* fixes #3011; handles meta fields defined in the ref object (#23818)ringabout2024-07-112-12/+26
| | | | | | | | | | | | | | | | | | | | | | | fixes #3011 In https://github.com/nim-lang/Nim/pull/23532, meta fields that defined in the object are handled. In this PR, RefObjectTy is handled as well: ```nim type Type = ref object context: ref object ``` Ref alias won't trigger mata fields checking so there won't have cascaded errors on `TypeBase`. ```nim type TypeBase = object context: ref object Type = ref TypeBase context: ref object ```
* closes #22095; adds a test case (#23822)ringabout2024-07-111-0/+20
| | | closes #22095
* fixes #20865; fixes #20987; Missing bounds check in array slicing (#23814)ringabout2024-07-102-2/+18
| | | | fixes #20865 fixes #20987
* fixes #22389; fixes #19840; don't fold paths containing `addr` (#23807)ringabout2024-07-091-0/+15
| | | | fixes #22389; fixes #19840