mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-15 17:25:36 +00:00
Merge branch 'devel' into araq-ic5
This commit is contained in:
@@ -27,7 +27,9 @@ errors.
|
||||
|
||||
- With `-d:nimPreviewDuplicateModuleError`, importing two modules that share the same name becomes a compile-time error. This includes importing the same module more than once. Use `import foo as foo1` (or other aliases) to avoid collisions.
|
||||
|
||||
- Adds the switch `--mangle:nim|cpp`, which selects `nim` or `cpp` style name mangling when used with `debuginfo` on, defaults to `nim`. The default is changed from `cpp` to `nim`.
|
||||
- Adds the switch `--mangle:nim|cpp`, which selects `nim` or `cpp` style name mangling when used with `debuginfo` on, defaults to `cpp`.
|
||||
|
||||
- The second parameter of `succ`, `pred`, `inc`, and `dec` in `system` now accepts `SomeInteger` (previously `Ordinal`).
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ const
|
||||
optHints, optStackTrace, optLineTrace, # consider adding `optStackTraceMsgs`
|
||||
optTrMacros, optStyleCheck, optCursorInference}
|
||||
DefaultGlobalOptions* = {optThreadAnalysis, optExcessiveStackTrace,
|
||||
optJsBigInt64}
|
||||
optJsBigInt64, optItaniumMangle}
|
||||
|
||||
proc getSrcTimestamp(): DateTime =
|
||||
try:
|
||||
|
||||
@@ -3054,6 +3054,13 @@ proc semExport(c: PContext, n: PNode): PNode =
|
||||
|
||||
s = nextOverloadIter(o, c, a)
|
||||
|
||||
proc isTypeTupleField(n: PNode): bool {.inline.} =
|
||||
result = n.typ.kind == tyTypeDesc or
|
||||
(n.typ.kind == tyGenericParam and n.typ.sym.kind == skGenericParam)
|
||||
# `skGenericParam` stays as `tyGenericParam` type rather than being wrapped in `tyTypeDesc`
|
||||
# would check if `n` itself is an `skGenericParam` symbol, but these symbols semcheck to an ident
|
||||
# maybe check if `n` is an ident to ensure this is not a value with the generic param type?
|
||||
|
||||
proc semTupleConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType = nil): PNode =
|
||||
result = semTuplePositionsConstr(c, n, flags, expectedType)
|
||||
if result.typ.kind == tyFromExpr:
|
||||
@@ -3064,10 +3071,10 @@ proc semTupleConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PTyp
|
||||
var isTupleType: bool = false
|
||||
if tupexp.len > 0: # don't interpret () as type
|
||||
internalAssert c.config, tupexp.kind == nkTupleConstr
|
||||
isTupleType = tupexp[0].typ.kind == tyTypeDesc
|
||||
isTupleType = isTypeTupleField(tupexp[0])
|
||||
# check if either everything or nothing is tyTypeDesc
|
||||
for i in 1..<tupexp.len:
|
||||
if isTupleType != (tupexp[i].typ.kind == tyTypeDesc):
|
||||
if isTupleType != isTypeTupleField(tupexp[i]):
|
||||
return localErrorNode(c, n, tupexp[i].info, "Mixing types and values in tuples is not allowed.")
|
||||
if isTupleType: # expressions as ``(int, string)`` are reinterpret as type expressions
|
||||
result = n
|
||||
|
||||
@@ -91,7 +91,7 @@ Advanced options:
|
||||
--os:SYMBOL set the target operating system (cross-compilation)
|
||||
--cpu:SYMBOL set the target processor (cross-compilation)
|
||||
--debuginfo:on|off enables debug information
|
||||
--mangle:nim|cpp selects `nim` or `cpp` style name mangling, defaults to `nim`
|
||||
--mangle:nim|cpp selects `nim` or `cpp` style name mangling, defaults to `cpp`
|
||||
-t, --passC:OPTION pass an option to the C compiler
|
||||
-l, --passL:OPTION pass an option to the linker
|
||||
--cc:SYMBOL specify the C compiler
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{.push stack_trace: off.}
|
||||
|
||||
proc succ*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Succ", noSideEffect.} =
|
||||
proc succ*[T: Ordinal, V: SomeInteger](x: T, y: V = 1): T {.magic: "Succ", noSideEffect.} =
|
||||
## Returns the `y`-th successor (default: 1) of the value `x`.
|
||||
##
|
||||
## If such a value does not exist, `OverflowDefect` is raised
|
||||
@@ -9,7 +9,7 @@ proc succ*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Succ", noSideEffect.} =
|
||||
assert succ(5) == 6
|
||||
assert succ(5, 3) == 8
|
||||
|
||||
proc pred*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Pred", noSideEffect.} =
|
||||
proc pred*[T: Ordinal, V: SomeInteger](x: T, y: V = 1): T {.magic: "Pred", noSideEffect.} =
|
||||
## Returns the `y`-th predecessor (default: 1) of the value `x`.
|
||||
##
|
||||
## If such a value does not exist, `OverflowDefect` is raised
|
||||
@@ -18,7 +18,7 @@ proc pred*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Pred", noSideEffect.} =
|
||||
assert pred(5) == 4
|
||||
assert pred(5, 3) == 2
|
||||
|
||||
proc inc*[T, V: Ordinal](x: var T, y: V = 1) {.magic: "Inc", noSideEffect.} =
|
||||
proc inc*[T: Ordinal, V: SomeInteger](x: var T, y: V = 1) {.magic: "Inc", noSideEffect.} =
|
||||
## Increments the ordinal `x` by `y`.
|
||||
##
|
||||
## If such a value does not exist, `OverflowDefect` is raised or a compile
|
||||
@@ -30,7 +30,7 @@ proc inc*[T, V: Ordinal](x: var T, y: V = 1) {.magic: "Inc", noSideEffect.} =
|
||||
inc(i, 3)
|
||||
assert i == 6
|
||||
|
||||
proc dec*[T, V: Ordinal](x: var T, y: V = 1) {.magic: "Dec", noSideEffect.} =
|
||||
proc dec*[T: Ordinal, V: SomeInteger](x: var T, y: V = 1) {.magic: "Dec", noSideEffect.} =
|
||||
## Decrements the ordinal `x` by `y`.
|
||||
##
|
||||
## If such a value does not exist, `OverflowDefect` is raised or a compile
|
||||
|
||||
@@ -93,7 +93,7 @@ pkg "lockfreequeues"
|
||||
pkg "loopfusion"
|
||||
pkg "macroutils"
|
||||
pkg "manu"
|
||||
pkg "markdown"
|
||||
pkg "markdown", "nim c -r tests/testmarkdown.nim"
|
||||
pkg "measuremancer", "nimble testDeps; nimble -y test"
|
||||
pkg "memo"
|
||||
pkg "metrics"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
targets: "c cpp"
|
||||
matrix: "--debugger:native --mangle:cpp"
|
||||
matrix: "--debugger:native --mangle:cpp; --debugger:native"
|
||||
ccodecheck: "'_ZN14titaniummangle8testFuncE'"
|
||||
ccodecheck: "'_ZN14titaniummangle8testFuncE6stringN14titaniummangle3FooE'"
|
||||
ccodecheck: "'_ZN14titaniummangle8testFuncE3int7varargsI6stringE'"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
matrix: "--debugger:native --mangle:nim; --debugger:native"
|
||||
matrix: "--debugger:native --mangle:nim"
|
||||
ccodecheck: "'testFunc__titaniummangle95nim_u1316'"
|
||||
ccodecheck: "'testFunc__titaniummangle95nim_u156'"
|
||||
ccodecheck: "'testFunc__titaniummangle95nim_u1305'"
|
||||
|
||||
34
tests/tuples/tgenericparamtypetuple.nim
Normal file
34
tests/tuples/tgenericparamtypetuple.nim
Normal file
@@ -0,0 +1,34 @@
|
||||
# issue #25312
|
||||
|
||||
import heapqueue
|
||||
|
||||
proc test1[T](test: (float, T)) = # Works
|
||||
discard
|
||||
|
||||
proc test2[T](test: seq[(float, T)]) = # Works
|
||||
discard
|
||||
|
||||
proc test3[T](test: HeapQueue[tuple[sqd: float, data: T]]) = # Works
|
||||
discard
|
||||
|
||||
proc test4(test: HeapQueue[(float, float)]) = # Works
|
||||
discard
|
||||
|
||||
type ExampleObj = object
|
||||
a: string
|
||||
b: seq[float]
|
||||
|
||||
proc test5(test: HeapQueue[(float, ExampleObj)]) = # Works
|
||||
discard
|
||||
|
||||
proc failingTest[T](test: HeapQueue[(float, T)]) = # (Compile) Error: Mixing types and values in tuples is not allowed.
|
||||
discard
|
||||
|
||||
proc failingTest2[T](test: HeapQueue[(T, float)]) = # (Compile) Error: Mixing types and values in tuples is not allowed.
|
||||
discard
|
||||
|
||||
proc test6[T](test: HeapQueue[(T, T)]) = # works
|
||||
discard
|
||||
|
||||
proc test7[T, U](test: HeapQueue[(T, U)]) = # works
|
||||
discard
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
errormsg: "type mismatch: got <int>"
|
||||
nimout: '''tprevent_forloopvar_mutations.nim(16, 3) Error: type mismatch: got <int>
|
||||
but expected one of:
|
||||
proc inc[T, V: Ordinal](x: var T; y: V = 1)
|
||||
proc inc[T: Ordinal; V: SomeInteger](x: var T; y: V = 1)
|
||||
first type mismatch at position: 1
|
||||
required type for x: var T: Ordinal
|
||||
but expression 'i' is immutable, not 'var'
|
||||
|
||||
Reference in New Issue
Block a user