summary refs log tree commit diff stats
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* fixes #23759; rework move for refc (#23764)ringabout2024-06-292-3/+9
| | | fixes #23759
* fixes #9940; genericAssign does not take care of the importC variables in ↵ringabout2024-06-261-1/+1
| | | | | refc [backport] (#23761) fixes #9940
* adapt semOpAux to opt-in symchoices (#23750)metagn2024-06-251-1/+1
| | | | | | | | 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.
* [backport] fixes #23711; C code contains backtick`gensym (#23716)ringabout2024-06-195-7/+15
| | | fixes #23711
* adds a define nimHasJsNoLambdaLifting so we can use it in the config for ↵ringabout2024-06-191-0/+1
| | | | compatibility (#23736)
* IC: use tables instead of huge seqs because the compiler can create l… ↵Andreas Rumpf2024-06-185-49/+67
| | | | | (#23737) …ots of dummy syms and types
* ignore uninstantiated static on match to base type [backport:2.0] (#23731)metagn2024-06-181-2/+5
| | | | | | | | | | | | | | | | | | | | | fixes #23730 Since #23188 the compiler errors when matching a type variable to an uninstantiated static value. However sometimes an uninstantiated static value is given even when only a type match is being performed to the base type of the static type, in the given issue this case is: ```nim proc foo[T: SomeInteger](x: T): int = int(x) proc bar(x: static int): array[foo(x), int] = discard discard bar(123) ``` To deal with this issue we only error when matching against a type variable constrained to `static`. Not sure if the `q.typ.kind == tyGenericParam and q.typ.genericConstraint == tyStatic` check is necessary, the code above for deciding whether the variable becomes `skConst` doesn't use it.
* implement `legacy:jsNoLambdaLifting` for compatibility (#23727)ringabout2024-06-174-19/+73
|
* fixes #20048; fixes #15746; don't sink object fields if it's of openarray ↵ringabout2024-06-151-1/+2
| | | | | | type (#23608) fixes #20048 fixes #15746
* ref #20653; fixes chronos empty case branches (#23706)ringabout2024-06-141-7/+11
| | | | | | | | | | | | | | | ref #20653 ```nim Error* = object case kind*: ErrorType of ErrorA: discard of ErrorB: discard ``` For an object variants without fields, it shouldn't generate empty brackets for default values since there are no fields at all in case branches.
* fixes a long standing bug with varargs type inference [backport] (#23720)Andreas Rumpf2024-06-141-1/+1
|
* nrvo for embedded importc'ed types (#23708)ringabout2024-06-121-3/+6
|
* [backport] fixes #23690; SIGSEGV with object variants and RTTI (#23703)ringabout2024-06-111-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23690 ```nim dest.`:state` = src.`:state` var :tmp_553651276 = dest.e1.a `=wasMoved`(dest.e1.a) dest.e1.a.kind = src.e1.a.kind case dest.e1.a.kind of 0: dest.e1.a.a = src.e1.a.a of 1: `=copy`(dest.e1.a.c, src.e1.a.c) case :tmp_553651276.kind of 0: of 1: `=destroy`(:tmp_553651276.c) ``` `dest.e1.a.kind = src.e1.a.kind` changes the discrimant but it fails to clear the memory of `dest.e1.a`. Before using hooks for copying, we need to clear the dest, e.g. `=wasMoved(dest.e1.a.c)`. ```nim dest.`:state` = src.`:state` var :tmp_553651276 = dest.e1.a `=wasMoved`(dest.e1.a) dest.e1.a.kind = src.e1.a.kind case dest.e1.a.kind of 0: `=wasMoved`(dest.e1.a.a) dest.e1.a.a = src.e1.a.a `=wasMoved`(dest.e1.a.b) of 1: `=wasMoved`(dest.e1.a.c) `=copy`(dest.e1.a.c, src.e1.a.c) case :tmp_553651276.kind of 0: of 1: `=destroy`(:tmp_553651276.c) ```
* fixes #22398; [backport] (#23704)Andreas Rumpf2024-06-101-9/+13
|
* fixes #23445; fixes #23418 [backport] (#23699)Andreas Rumpf2024-06-092-1/+12
|
* fixes #23354; [backport] (#23685)Andreas Rumpf2024-06-071-0/+3
|
* fixes #22672; Destructor not called for result when exception is thrown (#23267)ringabout2024-06-063-3/+40
| | | fixes #22672
* fixes #5901 #21211; don't fold cast function types because of gcc 14 (#23683)ringabout2024-06-051-1/+2
| | | | | | | | | follow up https://github.com/nim-lang/Nim/pull/6265 fixes #5901 fixes #21211 It causes many problems with gcc14 if we fold the cast function types. Let's check what it will break
* fix noreturn/implicit discard check logic (#23681)metagn2024-06-052-73/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | fixes #10440, fixes #13871, fixes #14665, fixes #19672, fixes #23677 The false positive in #23677 was caused by behavior in `implicitlyDiscardable` where only the last node of `if`/`case`/`try` etc expressions were considered, as in the final node of the final branch (in this case `else`). To fix this we use the same iteration in `implicitlyDiscardable` that we use in `endsInNoReturn`, with the difference that for an `if`/`case`/`try` statement to be implicitly discardable, all of its branches must be implicitly discardable. `noreturn` calls are also considered implicitly discardable for this reason, otherwise stuff like `if true: discardableCall() else: error()` doesn't compile. However `endsInNoReturn` also had bugs, one where `finally` was considered in noreturn checking when it shouldn't, another where only `nkIfStmt` was checked and not `nkIfExpr`, and the node given for the error message was bad. So `endsInNoReturn` now skips over `skipForDiscardable` which no longer contains `nkIfStmt`/`nkCaseStmt`/`nkTryStmt`, stores the first encountered returning node in a var parameter for the error message, and handles `finally` and `nkIfExpr`. Fixing #23677 already broke a line in `syncio` so some package code might be affected.
* Add linux/loongarch64 support in 'compiler/installer.ini' (#23672)qiangxuhui2024-06-041-1/+1
| | | | | The files(like `build/build.sh`)generated by the command `koch csource` do not contain complete `linux/loongarch64` support. This patch will fix it.
* fixes openarray hoist with gcc 14 (#23647)ringabout2024-06-041-1/+16
| | | | | | | blocks https://github.com/nim-lang/Nim/pull/23673 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* rework ctypes with gcc 14 (#23636)ringabout2024-06-021-0/+5
|
* improve view types for jsgen; eliminate unnecessary copies of view types ↵ringabout2024-06-021-2/+2
| | | | (#23654)
* #Fixes #23657 C++ compilation fails with: 'T1_' was not declared in t… ↵Juan M Gómez2024-06-024-24/+49
| | | | | (#23666) …his scope
* fixes#23665; rework spawn with gcc 14 and fixes other tests (#23660)ringabout2024-06-021-2/+14
| | | fixes #23665
* fixes #22852; fixes #23435; fixes #23645; SIGSEGV when slicing string or ↵ringabout2024-05-271-1/+9
| | | | | | | | | | | | | | | | | | seq[T] with index out of range (#23279) follow up https://github.com/nim-lang/Nim/pull/23013 fixes #22852 fixes #23435 fixes #23645 reports rangeDefect correctly ```nim /workspaces/Nim/test9.nim(1) test9 /workspaces/Nim/lib/system/indices.nim(116) [] /workspaces/Nim/lib/system/fatal.nim(53) sysFatal Error: unhandled exception: value out of range: -2 notin 0 .. 9223372036854775807 [RangeDefect] ```
* Skip tyAlias inside semTypeTraits in case a concept accidently emits one ↵Jason Beetham2024-05-231-1/+1
| | | | (#23640)
* Minor refactoring (#23637)Andreas Rumpf2024-05-231-17/+15
|
* fixes `reifiedOpenArray`; `nkHiddenStdConv` is PathKinds1 not PathKinds0 ↵ringabout2024-05-221-2/+8
| | | | (#23633)
* fixes #23627; Simple destructor code gives invalid C (#23631)ringabout2024-05-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23627 ```nim type TestObj = object of RootObj TestTestObj = object of RootObj testo: TestObj proc `=destroy`(x: TestTestObj) = echo "Destructor for TestTestObj" proc testCaseT() = echo "\nTest Case T" let tt1 {.used.} = TestTestObj(testo: TestObj()) ``` When generating const object fields, it's likely that we need to generate type infos for the object, which may be an object with custom hooks. We need to generate potential consts in the hooks first. https://github.com/nim-lang/Nim/pull/20433 changed the semantics of initialization. It should evaluate`BracedInit` first.
* fixes #16671; openarray conversion for object construction (#23618)ringabout2024-05-161-3/+7
| | | | | fixes #16671 related to https://github.com/nim-lang/Nim/pull/18911
* Support NetBSD/aarch64 (#23616)PHO2024-05-161-1/+1
| | | | | I could trivially port Nim to NetBSD/aarch64 because it already supported NetBSD and aarch64. I only needed to generate `c_code` for this combination.
* fixes lifting subtype calling parent's hooks (#23612)ringabout2024-05-151-1/+4
| | | | | ref https://forum.nim-lang.org/t/11587 Tested with `gcc version 14.0.1 20240412` locally
* fixes openarray views default values in JS (#23607)ringabout2024-05-141-2/+2
|
* ignore modules when looking up symbol with expected type (#23597)metagn2024-05-141-1/+1
| | | | | | | | | | | | | | | | 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.
* Allow to `exportc` params. (#23396)Juan M Gómez2024-05-101-1/+1
| | | | By allowing `exportc` in params one can decide the name of a param or to dont mangle them.
* unordered enum for better interoperability with C (#23585)ringabout2024-05-102-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ref https://forum.nim-lang.org/t/11564 ```nim block: # unordered enum block: type unordered_enum = enum a = 1 b = 0 doAssert (ord(a), ord(b)) == (1, 0) block: type unordered_enum = enum a = 1 b = 0 c doAssert (ord(a), ord(b), ord(c)) == (1, 0, 2) block: type unordered_enum = enum a = 100 b c = 50 d doAssert (ord(a), ord(b), ord(c), ord(d)) == (100, 101, 50, 51) block: type unordered_enum = enum a = 7 b = 6 c = 5 d doAssert (ord(a), ord(b), ord(c), ord(d)) == (7, 6, 5, 8) ```
* remove bad type inference behavior for enum identifiers (#23588)metagn2024-05-101-7/+0
| | | | | | | | | | | | | | | 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.
* fixes #23552; Invalid codegen when trying to mannualy delete distinct seq ↵ringabout2024-05-081-6/+8
| | | | | (#23558) fixes #23552
* fix semFinishOperands for bracket expressions [backport:2.0] (#23571)metagn2024-05-081-7/+8
| | | | | | | | | | | | | | | | fixes #23568, fixes #23310 In #23091 `semFinishOperands` was changed to not be called for `mArrGet` and `mArrPut`, presumably in preparation for #23188 (not sure why it was needed in #23091, maybe they got mixed together), since the compiler handles these later and needs the first argument to not be completely "typed" since brackets can serve as explicit generic instantiations in which case the first argument would have to be an unresolved generic proc (not accepted by `finishOperand`). In this PR we just make it so `mArrGet` and `mArrPut` specifically skip calling `finishOperand` on the first argument. This way the generic arguments in the explicit instantiation get typed, but not the unresolved generic proc.
* rework `wasMoved`, `move` on the JS backend (#23577)ringabout2024-05-087-27/+12
| | | | | `reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future
* fixes #22409; don't check style for enumFieldSymChoice in the function (#23580)ringabout2024-05-083-6/+7
| | | fixes #22409
* Skips generic owner when mangling instances (#23563)Juan M Gómez2024-05-071-1/+1
|
* fixes #23419; internal error with void in generic array instantiation (#23550)ringabout2024-05-011-3/+6
| | | | | | | | | fixes #23419 `void` is only supported as fields of objects/tuples. It shouldn't allow void in the array. I didn't merge it with taField because that flag is also used for tyLent, which is allowed in the fields of other types.
* fixes #23321; Error: internal error: openArrayLoc: ref array[0..0, int] (#23548)ringabout2024-04-291-1/+4
| | | | | | | | fixes #23321 In the function `mapType`, ptrs (tyPtr, tyVar, tyLent, tyRef) are mapped into ctPtrToArray, the dereference of which is skipped in the `genref`. We need to skip these ptrs in the function `genOpenArraySlice`.
* fixes #23531; fixes invalid meta type accepted in the object fields (#23532)ringabout2024-04-261-9/+17
| | | | | fixes #23531 fixes #19546 fixes #6982
* fixes #23536; Stack trace with wrong line number when the proc called inside ↵ringabout2024-04-261-6/+8
| | | | | for loop (#23540) fixes #23536
* fixes #23522; fixes pre-existing wrong type for iter in `liftIterSym` (#23538)ringabout2024-04-261-2/+1
| | | fixes #23522
* fixes #23525; an 'emit' pragma cannot be pushed (#23537)ringabout2024-04-241-0/+13
| | | fixes #23525
* adds another fix for concept in JS (#23535)ringabout2024-04-241-1/+1
| | | ref https://github.com/nim-lang/Nim/issues/9550