mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 10:54:42 +00:00
fixes #297
This commit is contained in:
32
tests/typerel/texplicitcmp.nim
Normal file
32
tests/typerel/texplicitcmp.nim
Normal file
@@ -0,0 +1,32 @@
|
||||
discard """
|
||||
output: '''[1 2 3 ]
|
||||
[1 2 3 ]
|
||||
[1 2 3 ]'''
|
||||
"""
|
||||
|
||||
# bug #297
|
||||
|
||||
import json, tables, algorithm
|
||||
|
||||
proc outp(a: openarray[int]) =
|
||||
stdout.write "["
|
||||
for i in a: stdout.write($i & " ")
|
||||
stdout.write "]\n"
|
||||
|
||||
proc works() =
|
||||
var f = @[3, 2, 1]
|
||||
sort(f, system.cmp[int])
|
||||
outp(f)
|
||||
|
||||
proc weird(json_params: TTable) =
|
||||
var f = @[3, 2, 1]
|
||||
# The following line doesn't compile: type mismatch. Why?
|
||||
sort(f, system.cmp[int])
|
||||
outp(f)
|
||||
|
||||
when isMainModule:
|
||||
var t = @[3, 2, 1]
|
||||
sort(t, system.cmp[int])
|
||||
outp(t)
|
||||
works()
|
||||
weird(initTable[string, TJsonNode]())
|
||||
Reference in New Issue
Block a user