Merge remote-tracking branch 'upstream/devel' into pr_object

This commit is contained in:
ringabout
2023-03-24 23:29:14 +08:00
29 changed files with 188 additions and 64 deletions

View File

@@ -5,6 +5,7 @@ discard """
t20588.nim(20, 12) Error: illegal type conversion to 'auto'
t20588.nim(21, 14) Error: illegal type conversion to 'typed'
t20588.nim(22, 16) Error: illegal type conversion to 'untyped'
t20588.nim(24, 7) Error: illegal type conversion to 'any'
'''
"""
@@ -16,7 +17,9 @@ t20588.nim(22, 16) Error: illegal type conversion to 'untyped'
discard 0.0.auto
discard typed("abc")
discard untyped(4)
var a = newSeq[bool](1000)
if any(a):
echo "ok?"

View File

@@ -0,0 +1,10 @@
import std/typetraits
type Foo* = distinct string
converter toBase*(headers: var Foo): var string =
headers.distinctBase
proc bar*(headers: var Foo) =
for x in headers: discard

6
tests/generics/m3770.nim Normal file
View File

@@ -0,0 +1,6 @@
type
Noice* = object
hidden: int
template jjj*: Noice =
Noice(hidden: 15)

9
tests/generics/t3770.nim Normal file
View File

@@ -0,0 +1,9 @@
# bug #3770
import m3770
doAssert $jjj() == "(hidden: 15)" # works
proc someGeneric(_: type) =
doAssert $jjj() == "(hidden: 15)" # fails: "Error: the field 'hidden' is not accessible."
someGeneric(int)

View File

@@ -388,6 +388,11 @@ block: # newSeqWith tests
seq2D[0][1] = true
doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]]
block: # bug #21538
var x: seq[int] = @[2, 4]
var y = newSeqWith(x.pop(), true)
doAssert y == @[true, true, true, true]
block: # mapLiterals tests
let x = mapLiterals([0.1, 1.2, 2.3, 3.4], int)
doAssert x is array[4, int]

View File

@@ -99,3 +99,18 @@ block: # bug #21290
doAssert s == """<foo>
<bar>Hola<qux> <plugh /> </qux></bar>
</foo>"""
block: #21541
let root = <>root()
root.add <>child(newText("hello"))
root.add <>more(newVerbatimText("hola"))
let s = $root
doAssert s == """<root>
<child>hello</child>
<more>hola</more>
</root>"""
let temp = newVerbatimText("Hello!")
doAssert temp.text == "Hello!"
temp.text = "Hola!"
doAssert temp.text == "Hola!"