| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
cstring to string via cstrToNimstr (#23371)
fixes #12703
ref #19588
|
|
|
|
|
|
|
|
|
| |
static/dynlib libraries (#23357)
fixes #20945
fixes #18262
todo
- [ ] perhaps export with lib prefix when the option is enabled
|
|
|
|
| |
Unfortunately we cant trick the debugger when targeting C++ so this one
also needs to wait for our own debugger adapter.
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, I don't have syntax highlighting (+ no/wrong
jump-to-definition) for some import statement forms, namely:
- `import module/name/with/(slashes)`
- `import (mod) as alias`
- `import basemod/[ (sub1), (sub2) ]`
With this patch, highlight/def will work for the regions indicated by
parentheses.
|
|
|
| |
fixes #23273
|
|
|
|
|
|
|
|
|
| |
ref #23354
The new move analyzer requires types that have the tfAsgn flag
(otherwise `lastRead` will return true); tfAsgn is included when the
destructor is not trival. But it should consider the assignement for
objects in this case because objects might have a trival destructors but
it's the assignement that matters when it is passed to sink parameters.
|
|
|
|
|
|
| |
fixes #13481;
fixes #22708
Otherwise it gives implicit results or bad codegen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is just one of those tiny steps towards the goal of an "optimized"
C and C++ codegen I raised elsewhere before - what does me babbling
"optimized" mainly entail?
(not mutually-exclusive ascertainment proposals following:)
- less and simplified resulting code: easier to pick up/grasp for the
C/C++ compiler for to do its own optimization heuristics, less parsing
effort for us mere humans trying to debug, especially in the case of
interop
- build time reduction: less code emission I/O, runtime string
formatting for output...
- easier access for fresh contributors and better maintainability
- interop improvements
- further runtime optimizations
I am eagerly looking forward to the results of the LLVM-based
undertakings, but I also think we can do a bit better (as outlined
above) with our current C/C++ backends till those come to fruition.
**Long story short**: this PR here focuses on the C++ backend,
augmenting the current codegen method of establishing "temporary"
variables by using C++11's auto type deduction. The reasons for adopting
an "Almost Always Auto" style have been collected [here
](https://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/)
for the C++ world. For those hopping between C++'s and Nim's realms,
this change also results in a bit less code and less work for the
codegen part (no redundant `getTypeDesc`s): no need to tell the C++
compiler the type it already knows of (in most cases).
|
|
|
|
|
| |
(#23363)
…ort]
|
|
|
|
|
|
| |
ref https://forum.nim-lang.org/t/11052

|
|
|
|
| |
iterators and try/catch-like constructions (#23317)
|
|
|
|
| |
outside of a 'type' block (#23331)
|
|
|
| |
fixes #22723
|
|
|
|
|
|
|
| |
constains -> constrains
---------
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
|
| |
|
|
|
|
| |
"msg".} pragma. (#23325)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes an oversight with a change that I made a while ago.
Basically, these two snippets should both compile. Currently the
`varargs` version will fail.
```nim
template s(d: typed)=discard
proc something()=discard
proc something(x:int)=discard
s(something)
```
```nim
template s(d: varargs[typed])=discard
proc something()=discard
proc something(x:int)=discard
s(something)
```
Potentially unrelated, but this works currently for some reason:
```nim
template s(a: varargs[typed])=discard
proc something()=discard
proc something(x:int)=discard
s:
something
```
also, this works:
```nim
template s(b:untyped, a: varargs[typed])=discard
proc something()=discard
proc something(x:int)=discard
s (g: int):
something
```
but this doesn't, and the error message is not what I would expect:
```nim
template s(b:untyped, a: varargs[typed])=discard
proc something()=discard
proc something(x:int)=discard
s (g: int), something
```
So far as I can tell, none of these issues persist for me after the code
changes in this PR.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following would crash nimsuggest on init:
```nim
import chronos
type
HistoryQuery = object
start: int
limit: int
HistoryResult = object
messages: string
type HistoryQueryHandler* = proc(req: HistoryQuery): Future[HistoryResult] {.async, gcsafe.}
```
|
|
|
| |
fixes #23295
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#23323)
…hich conveys effects beyond its module scope for C/C++
codegen(suppresses current UnusedImport warning)
Just a minor inconvenience working in the area of C/C++ integration I
guess, but here we go:
I noticed receiving ```UnusedImport``` warnings for modules having only
```passC```/```passL```/```compile``` pragmas around. I gather the
compiler cannot actually infer those modules being unused as they *may*
have consequences for the whole build process (as they did in my simple
case).
Thus, I hereby suggest adding the `sfUsed` flag to the respective module
in order to suppress the compiler's warning.
I reckon other pragmas should be put into consideration as well: I will
keep up the investigation with PR followups.
|
|
|
| |
fixes https://forum.nim-lang.org/t/10807
|
|
|
| |
fixes #18104
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
call stack (#23260)

---------
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
|
|
|
|
|
| |
result (#23285)
fixes #23280
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
which corrupts the compiler (#23271)
fixes #22909
required by https://github.com/nim-lang/Nim/pull/23267
```nim
proc foo: string =
assert false
result = ""
```
In the function `foo`, `assert false` raises an exception, which can
cause `result` to be uninitialized if the default result initialization
is optimized out
|
|
|
|
| |
related https://github.com/nim-lang/Nim/issues/21717 configs will be
resolved later
|
| |
|
|
|
| |
fixes #19977
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #23247
closes #23251 (which accounts for why the openarray type is lifted
because ops are lifted for openarray conversions)
related: https://github.com/nim-lang/Nim/pull/18713
It seems to me that openarray doesn't own the data, so it cannot destroy
itself. The same case should be applied to
https://github.com/nim-lang/Nim/issues/19435. It shouldn't be destroyed
even openarray can have a destructor. A cleanup will be followed for
https://github.com/nim-lang/Nim/pull/19723 if it makes sense.
According to https://github.com/nim-lang/Nim/pull/12073, it lifts
destructor for openarray when openarray is sunk into the function, when
means `sink openarray` owns the data and needs to destroy it. In other
cases, destructor shouldn't be lifted for `openarray` in the first place
and it shouldn't destroy the data if it doesn't own it.
---------
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
|
|
|
| |
Fixes #23085
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #22597
```nim
proc autoToOpenArray*[T](s: Slice[T]): openArray[T] =
echo "here twice"
result = toOpenArray(s.p, s.first, s.last)
```
For functions returning openarray types, `fixupCall` creates a temporary
variable to store the return value: `let tmp = autoToOpenArray()`. But
`genOpenArrayConv` cannot handle openarray assignements with side
effects. It should have stored the right part of the assignment first
instead of calling the right part twice.
|
|
|
|
|
|
|
| |
assertion (#23242)
Closes #23240
Fixes regression caused by #23017
|
|
|
| |
fixes #23249
|
|
|
|
|
| |
(#23235)
fixes #23233
|
|
|
| |
fixes #22218
|
|
|
|
|
|
| |
fixes #12334
`nkHiddenStdConv` shouldn't be removed if the sources aren't literals,
viz. constant symbols.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #18125
Previously a tuple type like `(T, int)` would match an expected tuple
type `(U, int)` if `T` is a subtype of `U`. This is wrong since the
codegen does not handle type conversions of individual tuple elements in
a type conversion of an entire tuple. For this reason the compiler
already does not accept `(float, int)` for a matched type `(int, int)`,
however the code that checked for which relations are unacceptable
checked for `< isSubtype` rather than `<= isSubtype`, so subtypes were
not included in the unacceptable relations.
Update: Now only considered unacceptable when inheritance is used, as in
[`paramTypesMatch`](https://github.com/nim-lang/Nim/blob/3379d26629f30e6be8d303a36e220d1039eb4551/compiler/sigmatch.nim#L2252-L2254).
Ideally subtype relations that don't need conversions, like `nil`,
`seq[empty]`, `range[0..5]` etc would be their own relation
`isConcreteSubtype` (which would also allow us to differentiate with
`openArray[T]`), but this is too big of a refactor for now.
To compensate for this making things like `let x: (Parent, int) =
(Child(), 0)` not compile (they would crash codegen before anyway but
should still work in principle), type inference for tuple constructors
is updated such that they call `fitNode` on the fields and their
expected types, so a type conversion is generated for the individual
subtype element.
|
|
|
|
|
|
|
|
|
|
| |
fixes #17163, refs #23204
Types that aren't `tyRange` and are bigger than 16 bits, so `int32`,
`uint64`, `int` etc, are disallowed as array index range types.
`tyRange` is excluded because the max array size is backend independent
(except for the specific size of `high(uint64)` which crashes the
compiler) and so there should still be an escape hatch for people who
want bigger arrays.
|
|
|
|
|
|
| |
Change to `compiler/installer.ini` to add `nimdoc.cls` to files copied
by installer script.
Closes #23231
|
|
|
|
|
|
|
| |
fixes https://github.com/nim-lang/Nim/issues/23112, fixes a mistake in
https://github.com/nim-lang/Nim/pull/22581
This makes `getType(t)` where `t` is a typedesc param with value `T`
equal to `getType(T)`.
|
|
|
|
|
|
| |
This PR modifies `specializeResetT` so that it generates the proper
reset code for range types. I've tested it in the examples for issues
#23214 and #22462 as well as our codebase, and it seems to fix the
issues I had been experiencing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #23200, fixes #18866
#21065 made it so `auto` proc return types remained as `tyAnything` and
not turned to `tyUntyped`. This had the side effect that anything
previously bound to `tyAnything` in the proc type match was then bound
to the proc return type, which is wrong since we don't know the proc
return type even if we know the expected parameter types (`tyUntyped`
also [does not care about its previous bindings in
`typeRel`](https://github.com/nim-lang/Nim/blob/ab4278d2179639f19967431a7aa1be858046f7a7/compiler/sigmatch.nim#L1059-L1061)
maybe for this reason).
Now we mark `tyAnything` return types for routines as `tfRetType` [as
done for other meta return
types](https://github.com/nim-lang/Nim/blob/18b5fb256d4647efa6a64df451d37129d36e96f3/compiler/semtypes.nim#L1451),
and ignore bindings to `tyAnything` + `tfRetType` types in `semtypinst`.
On top of this, we reset the type relation in `paramTypesMatch` only
after creating the instantiation (instead of trusting
`isInferred`/`isInferredConvertible` before creating the instantiation),
using the same mechanism that `isBothMetaConvertible` uses.
This fixes the issues as well as making the disabled t15386_2 test
introduced in #21065 work. As seen in the changes for the other tests,
the error messages give an obscure `proc (a: GenericParam): auto` now,
but it does give the correct error that the overload doesn't match
instead of matching the overload pre-emptively and expecting a specific
return type.
tsugar had to be changed due to #16906, which is the problem where
`void` is not inferred in the case where `result` was never touched.
|
|
|
|
| |
don't have an explicit `.raises` pragma (#23193)
|
|
|
|
|
|
| |
loop (#23185)
fixes #23180
fixes #19805
|
|
|
| |
fixes #15924
|
|
|
| |
fixes #22923
|
|
|
|
|
| |
raise (#23195)
fixes #23129
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
statics (#23188)
fixes #23186
As explained in #23186, generics can transform `genericProc[int]` into a
call `` `[]`(genericProc, int) `` which causes a problem when
`genericProc` is resemmed, since it is not a resolved generic proc. `[]`
needs unresolved generic procs since `mArrGet` also handles explicit
generic instantiations, so delay the resolved generic proc check to
`semFinishOperands` which is intentionally not called for `mArrGet`.
The root issue for
[t6137](https://github.com/nim-lang/Nim/blob/devel/tests/generics/t6137.nim)
is also fixed (because this change breaks it otherwise), the compiler
doesn't consider the possibility that an assigned generic param can be
an unresolved static value (note the line `if t.kind == tyStatic: s.ast
= t.n` below the change in sigmatch), now it properly errors that it
couldn't instantiate it as it would for a type param. ~~The change in
semtypinst is just for symmetry with the code above it which also gives
a `cannot instantiate` error, it may or may not be necessary/correct.~~
Now removed, I don't think it was correct.
Still possible that this has unintended consequences.
|