tvmmisc.nim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. import macros
  2. import os
  3. # bug #4462
  4. block:
  5. proc foo(t: typedesc) {.compileTime.} =
  6. assert sameType(getType(t), getType(int))
  7. static:
  8. foo(int)
  9. # bug #4412
  10. block:
  11. proc default[T](t: typedesc[T]): T {.inline.} = discard
  12. static:
  13. var x = default(type(0))
  14. # bug #6379
  15. import algorithm
  16. static:
  17. var numArray = [1, 2, 3, 4, -1]
  18. numArray.sort(cmp)
  19. doAssert numArray == [-1, 1, 2, 3, 4]
  20. var str = "cba"
  21. str.sort(cmp)
  22. doAssert str == "abc"
  23. # bug #6086
  24. import math, sequtils, sugar
  25. block:
  26. proc f: int =
  27. toSeq(10..<10_000).filter(
  28. a => a == ($a).map(
  29. d => (d.ord-'0'.ord).int^4
  30. ).sum
  31. ).sum
  32. var a = f()
  33. const b = f()
  34. doAssert a == b
  35. block:
  36. proc f(): seq[char] =
  37. result = "hello".map(proc(x: char): char = x)
  38. var runTime = f()
  39. const compTime = f()
  40. doAssert runTime == compTime
  41. # #6083
  42. block:
  43. proc abc(): seq[int] =
  44. result = @[0]
  45. result.setLen(2)
  46. var tmp: int
  47. for i in 0 ..< 2:
  48. inc tmp
  49. result[i] = tmp
  50. const fact1000 = abc()
  51. doAssert fact1000 == @[1, 2]
  52. # Tests for VM ops
  53. block:
  54. static:
  55. # for joint test, the project path is different, so I disabled it:
  56. when false:
  57. doAssert "vm" in getProjectPath()
  58. let b = getEnv("UNSETENVVAR")
  59. doAssert b == ""
  60. doAssert existsEnv("UNSERENVVAR") == false
  61. putEnv("UNSETENVVAR", "VALUE")
  62. doAssert getEnv("UNSETENVVAR") == "VALUE"
  63. doAssert existsEnv("UNSETENVVAR") == true
  64. doAssert fileExists("MISSINGFILE") == false
  65. doAssert dirExists("MISSINGDIR") == false
  66. doAssert fileExists(currentSourcePath())
  67. doAssert dirExists(currentSourcePath().parentDir)
  68. # bug #7210
  69. block:
  70. static:
  71. proc f(size: int): int =
  72. var some = newStringOfCap(size)
  73. result = size
  74. doAssert f(4) == 4
  75. # bug #6689
  76. block:
  77. static:
  78. proc foo(): int = 0
  79. var f: proc(): int
  80. doAssert f.isNil
  81. f = foo
  82. doAssert(not f.isNil)
  83. block:
  84. static:
  85. var x: ref ref int
  86. new(x)
  87. doAssert(not x.isNil)
  88. # bug #7871
  89. static:
  90. type Obj = object
  91. field: int
  92. var s = newSeq[Obj](1)
  93. var o = Obj()
  94. s[0] = o
  95. o.field = 2
  96. doAssert s[0].field == 0
  97. # bug #8125
  98. static:
  99. let def_iter_var = ident("it")
  100. # bug #8142
  101. static:
  102. type Obj = object
  103. names: string
  104. proc pushName(o: var Obj) =
  105. var s = ""
  106. s.add("FOOBAR")
  107. o.names.add(s)
  108. var o = Obj()
  109. o.names = ""
  110. o.pushName()
  111. o.pushName()
  112. doAssert o.names == "FOOBARFOOBAR"
  113. # bug #8154
  114. import parseutils
  115. static:
  116. type Obj = object
  117. i: int
  118. proc foo(): Obj =
  119. discard parseInt("1", result.i, 0)
  120. static:
  121. doAssert foo().i == 1
  122. # bug #10333
  123. block:
  124. const
  125. encoding: auto = [
  126. ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"],
  127. ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"],
  128. ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"],
  129. ["", "M", "MM", "MMM", "--", "-", "--", "---", "----", "--"],
  130. ]
  131. doAssert encoding.len == 4
  132. # bug #10886
  133. proc tor(): bool =
  134. result = true
  135. result = false or result
  136. proc tand(): bool =
  137. result = false
  138. result = true and result
  139. const
  140. ctor = tor()
  141. ctand = not tand()
  142. static:
  143. doAssert ctor
  144. doAssert ctand
  145. block: # bug #13081
  146. type Kind = enum
  147. k0, k1, k2, k3
  148. type Foo = object
  149. x0: float
  150. case kind: Kind
  151. of k0: discard
  152. of k1: x1: int
  153. of k2: x2: string
  154. of k3: x3: string
  155. const j1 = Foo(x0: 1.2, kind: k1, x1: 12)
  156. const j2 = Foo(x0: 1.3, kind: k2, x2: "abc")
  157. const j3 = Foo(x0: 1.3, kind: k3, x3: "abc2")
  158. static:
  159. doAssert $j1 == "(x0: 1.2, kind: k1, x1: 12)"
  160. doAssert $j2 == """(x0: 1.3, kind: k2, x2: "abc")"""
  161. doAssert $j3 == """(x0: 1.3, kind: k3, x3: "abc2")"""
  162. doAssert $j1 == "(x0: 1.2, kind: k1, x1: 12)"
  163. doAssert $j2 == """(x0: 1.3, kind: k2, x2: "abc")"""
  164. doAssert $j3 == """(x0: 1.3, kind: k3, x3: "abc2")"""
  165. doAssert j1.x1 == 12
  166. static:
  167. doAssert j1.x1 == 12
  168. block: # bug #15595
  169. proc fn0()=echo 0
  170. proc fn1()=discard
  171. proc main=
  172. var local = 0
  173. proc fn2()=echo local
  174. var a0 = fn0
  175. var a1 = fn1
  176. var a2 = fn2
  177. var a3: proc()
  178. var a4: proc()
  179. doAssert a0 == fn0 # bugfix
  180. doAssert a1 == fn1 # ditto
  181. doAssert a2 == fn2 # ditto
  182. doAssert fn0 != fn1
  183. doAssert a2 != nil
  184. doAssert a3 == nil # bugfix
  185. doAssert a3 == a4 # bugfix
  186. static: main()
  187. main()
  188. block: # issue #20543
  189. type F = proc()
  190. const myArray = block:
  191. var r: array[1, F]
  192. r[0] = nil
  193. r
  194. doAssert isNil(myArray[0])
  195. # bug #15363
  196. import sequtils
  197. block:
  198. func identity(a: bool): bool = a
  199. var a: seq[bool] = static:
  200. newSeq[bool](0).mapIt(it) # segfaults
  201. var b: seq[bool] = static:
  202. newSeq[bool](0).filterIt(it) # does not segfault
  203. var c: seq[bool] = static:
  204. newSeq[bool](0).map(identity) # does not segfault
  205. var d: seq[bool] = static:
  206. newSeq[bool](0).map(proc (a: bool): bool = false) # segfaults
  207. var e: seq[bool] = static:
  208. newSeq[bool](0).filter(identity) # does not segfault
  209. var f: seq[bool] = static:
  210. newSeq[bool](0).filter(proc (a: bool): bool = false) # segfaults
  211. doAssert a == @[]
  212. doAssert b == @[]
  213. doAssert c == @[]
  214. doAssert d == @[]
  215. doAssert e == @[]
  216. doAssert f == @[]
  217. block: # bug #18310
  218. macro t() : untyped =
  219. let
  220. x = nnkTupleConstr.newTree(newLit(1))
  221. y = nnkTupleConstr.newTree(newLit(2))
  222. doAssert not (x == y) # not using != intentionally
  223. doAssert not(cast[int](x) == cast[int](y))
  224. doAssert not(system.`==`(x, y))
  225. doAssert system.`==`(x, x)
  226. t()
  227. block: # bug #10815
  228. type
  229. Opcode = enum
  230. iChar, iSet
  231. Inst = object
  232. case code: Opcode
  233. of iChar:
  234. c: char
  235. of iSet:
  236. cs: set[char]
  237. Patt = seq[Inst]
  238. proc `$`(p: Patt): string =
  239. discard
  240. proc P(): Patt =
  241. result.add Inst(code: iSet)
  242. const a = P()
  243. doAssert $a == ""
  244. import tables
  245. block: # bug #8007
  246. type
  247. CostKind = enum
  248. Fixed,
  249. Dynamic
  250. Cost = object
  251. case kind*: CostKind
  252. of Fixed:
  253. cost*: int
  254. of Dynamic:
  255. handler*: proc(value: int): int {.nimcall.}
  256. proc foo(value: int): int {.nimcall.} =
  257. sizeof(value)
  258. const a: array[2, Cost] =[
  259. Cost(kind: Fixed, cost: 999),
  260. Cost(kind: Dynamic, handler: foo)
  261. ]
  262. # OK with arrays & object variants
  263. doAssert $a == "[(kind: Fixed, cost: 999), (kind: Dynamic, handler: ...)]"
  264. const b: Table[int, Cost] = {
  265. 0: Cost(kind: Fixed, cost: 999),
  266. 1: Cost(kind: Dynamic, handler: foo)
  267. }.toTable
  268. # KO with Tables & object variants
  269. # echo b # {0: (kind: Fixed, cost: 0), 1: (kind: Dynamic, handler: ...)} # <----- wrong behaviour
  270. doAssert $b == "{0: (kind: Fixed, cost: 999), 1: (kind: Dynamic, handler: ...)}"
  271. const c: Table[int, int] = {
  272. 0: 100,
  273. 1: 999
  274. }.toTable
  275. # OK with Tables and primitive int
  276. doAssert $c == "{0: 100, 1: 999}"
  277. # For some reason the following gives
  278. # Error: invalid type for const: Cost
  279. const d0 = Cost(kind: Fixed, cost: 999)
  280. # OK with seq & object variants
  281. const d = @[Cost(kind: Fixed, cost: 999), Cost(kind: Dynamic, handler: foo)]
  282. doAssert $d == "@[(kind: Fixed, cost: 999), (kind: Dynamic, handler: ...)]"
  283. block: # bug #14340
  284. block:
  285. proc opl3EnvelopeCalcSin0() = discard
  286. type EnvelopeSinfunc = proc() {.nimcall.} # todo: fixme
  287. # const EnvelopeCalcSin0 = opl3EnvelopeCalcSin0 # ok
  288. const EnvelopeCalcSin0: EnvelopeSinfunc = opl3EnvelopeCalcSin0 # was bug
  289. const envelopeSin = [EnvelopeCalcSin0]
  290. var a = 0
  291. envelopeSin[a]()
  292. block:
  293. type Mutator = proc() {.noSideEffect, gcsafe.}
  294. proc mutator0() = discard
  295. const mTable = [Mutator(mutator0)]
  296. var i=0
  297. mTable[i]()
  298. block: # VM wrong register free causes errors in unrelated code
  299. block: # bug #15597
  300. #[
  301. Error: unhandled exception: 'sym' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect]
  302. in /Users/timothee/git_clone/nim/Nim_prs/compiler/vm.nim(1176) rawExecute
  303. in opcIndCall
  304. in let prc = if not isClosure: bb.sym else: bb[0].sym
  305. ]#
  306. proc bar2(head: string): string = "asdf"
  307. proc zook(u1: int) = discard
  308. type PathEntry = object
  309. kind: int
  310. path: string
  311. iterator globOpt(): int =
  312. var u1: int
  313. zook(u1)
  314. zook(u1)
  315. zook(u1)
  316. zook(u1)
  317. zook(u1)
  318. zook(u1)
  319. zook(u1)
  320. zook(u1)
  321. zook(u1)
  322. zook(u1)
  323. zook(u1)
  324. zook(u1)
  325. zook(u1)
  326. zook(u1)
  327. var entry = PathEntry()
  328. entry.path = bar2("")
  329. if false:
  330. echo "here2"
  331. proc processAux(a: float) = discard
  332. template bar(iter: untyped): untyped =
  333. var ret: float
  334. for x in iter: break
  335. ret
  336. proc main() =
  337. processAux(bar(globOpt()))
  338. static: main()
  339. block: # ditto
  340. # D20201024T133245
  341. type Deque = object
  342. proc initDeque2(initialSize: int = 4): Deque = Deque()
  343. proc len2(a: Deque): int = 2
  344. proc baz(dir: string): bool = true
  345. proc bar2(head: string): string = "asdf"
  346. proc bar3(path: var string) = path = path
  347. type PathEntry = object
  348. kind: int
  349. path: string
  350. proc initGlobOpt(dir: string, a1=false,a2=false,a3=false,a4=false): string = dir
  351. iterator globOpt(dir: string): int =
  352. var stack = initDeque2()
  353. doAssert baz("")
  354. let z = stack.len2
  355. if stack.len2 >= 0:
  356. var entry = PathEntry()
  357. let current = if true: stack.len2 else: stack.len2
  358. entry.path = bar2("")
  359. bar3(entry.path)
  360. if false:
  361. echo "here2" # comment here => you get same error as https://github.com/nim-lang/Nim/issues/15704
  362. proc processAux(a: float) = discard
  363. template bar(iter: untyped): untyped =
  364. var ret: float
  365. for x in iter: break
  366. ret
  367. proc main() =
  368. processAux(bar(globOpt(initGlobOpt("."))))
  369. static: main()
  370. block: # bug #15704
  371. #[
  372. Error: attempt to access a nil address kind: rkFloat
  373. ]#
  374. type Deque = object
  375. proc initDeque2(initialSize: int = 4): Deque = Deque()
  376. proc len2(a: Deque): int = 2
  377. proc baz(dir: string): bool = true
  378. proc bar2(head: string): string = "asdf"
  379. proc bar3(path: var string) = path = path
  380. type PathEntry = object
  381. kind: int
  382. path: string
  383. depth: int
  384. proc initGlobOpt(dir: string, a1=false,a2=false,a3=false,a4=false): string =
  385. dir
  386. iterator globOpt(dir: string): int =
  387. var stack = initDeque2()
  388. doAssert baz("")
  389. let z = stack.len2
  390. var a5: int
  391. if stack.len2 >= 0:
  392. var entry = PathEntry()
  393. if false:
  394. echo "here"
  395. let current = if true: stack.len2 else: stack.len2
  396. entry.depth = 1
  397. entry.path = bar2("")
  398. bar3(entry.path)
  399. proc processAux(a: float) = discard
  400. template bar(iter: untyped): untyped =
  401. var ret: float
  402. for x in iter:
  403. break
  404. ret
  405. const dir = "."
  406. proc main() =
  407. processAux(bar(globOpt(initGlobOpt(dir))))
  408. static: main()
  409. block: # bug #8015
  410. block:
  411. type Foo = object
  412. case b: bool
  413. of false: v1: int
  414. of true: v2: int
  415. const t = [Foo(b: false, v1: 1), Foo(b: true, v2: 2)]
  416. doAssert $t == "[(b: false, v1: 1), (b: true, v2: 2)]"
  417. doAssert $t[0] == "(b: false, v1: 1)" # was failing
  418. block:
  419. type
  420. CostKind = enum
  421. Fixed,
  422. Dynamic
  423. Cost = object
  424. case kind*: CostKind
  425. of Fixed:
  426. cost*: int
  427. of Dynamic:
  428. handler*: proc(): int {.nimcall.}
  429. proc foo1(): int {.nimcall.} =
  430. 100
  431. proc foo2(): int {.nimcall.} =
  432. 200
  433. # Change to `let` and it doesn't crash
  434. const costTable = [
  435. 0: Cost(kind: Fixed, cost: 999),
  436. 1: Cost(kind: Dynamic, handler: foo1),
  437. 2: Cost(kind: Dynamic, handler: foo2)
  438. ]
  439. doAssert $costTable[0] == "(kind: Fixed, cost: 999)"
  440. doAssert costTable[1].handler() == 100
  441. doAssert costTable[2].handler() == 200
  442. # Now trying to carry the table as an object field
  443. type
  444. Wrapper = object
  445. table: array[3, Cost]
  446. proc procNewWrapper(): Wrapper =
  447. result.table = costTable
  448. # Alternatively, change to `const` and it doesn't crash
  449. let viaProc = procNewWrapper()
  450. doAssert viaProc.table[1].handler != nil
  451. doAssert viaProc.table[2].handler != nil
  452. doAssert $viaProc.table[0] == "(kind: Fixed, cost: 999)"
  453. doAssert viaProc.table[1].handler() == 100
  454. doAssert viaProc.table[2].handler() == 200
  455. # bug #19198
  456. block:
  457. type
  458. Foo[n: static int] = int
  459. block:
  460. static:
  461. let x = int 1
  462. doAssert $(x.type) == "int" # Foo
  463. block:
  464. static:
  465. let x = int 1
  466. let y = x + 1
  467. # Error: unhandled exception: value out of range: -8 notin 0 .. 65535 [RangeDefect]
  468. doAssert y == 2
  469. type Atom* = object
  470. bar: int
  471. proc main() = # bug #12994
  472. var s: seq[Atom]
  473. var atom: Atom
  474. var checked = 0
  475. for i in 0..<2:
  476. atom.bar = 5
  477. s.add atom
  478. atom.reset
  479. if i == 0:
  480. checked += 1
  481. doAssert $s == "@[(bar: 5)]"
  482. else:
  483. checked += 1
  484. doAssert $s == "@[(bar: 5), (bar: 5)]"
  485. doAssert checked == 2
  486. static: main()
  487. main()
  488. # bug #19201
  489. proc foo(s: sink string) = doAssert s.len == 3
  490. static:
  491. foo("abc")
  492. static:
  493. for i in '1' .. '2': # bug #10938
  494. var s: set[char]
  495. doAssert s == {}
  496. incl(s, i)
  497. for _ in 0 ..< 3: # bug #13312
  498. var s: string
  499. s.add("foo")
  500. doAssert s == "foo"
  501. for i in 1 .. 5: # bug #13918
  502. var arr: array[3, int]
  503. var val: int
  504. doAssert arr == [0, 0, 0] and val == 0
  505. for j in 0 ..< len(arr):
  506. arr[j] = i
  507. val = i
  508. # bug #20985
  509. let a = block:
  510. var groups: seq[seq[int]]
  511. for i in 0 ..< 3:
  512. var group: seq[int]
  513. for j in 0 ..< 3:
  514. group.add j
  515. groups.add group
  516. groups
  517. const b = block:
  518. var groups: seq[seq[int]]
  519. for i in 0 ..< 3:
  520. var group: seq[int]
  521. for j in 0 ..< 3:
  522. group.add j
  523. groups.add group
  524. groups
  525. doAssert a == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]]
  526. doAssert b == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]]
  527. macro m1(s: string): int =
  528. var ProcID {.global, compileTime.}: int
  529. inc(ProcID)
  530. result = newLit(ProcID)
  531. proc macroGlobal =
  532. doAssert m1("Macro argument") == 1
  533. doAssert m1("Macro argument") == 2
  534. doAssert m1("Macro argument") == 3
  535. static: macroGlobal()
  536. macroGlobal()
  537. block: # bug #10108
  538. template reject(x) =
  539. static: doAssert(not compiles(x))
  540. static:
  541. let x: int = 2
  542. proc deliver_x(): int = x
  543. var y2 = deliver_x()
  544. discard y2
  545. reject:
  546. const c5 = deliver_x()
  547. block: # bug #7590
  548. proc doInit[T]():auto=
  549. var a: T
  550. return a
  551. proc fun2[T](tup1:T)=
  552. const tup0=doInit[T]()
  553. # var tup=tup0 #ok
  554. const tup=tup0 #causes bug
  555. doAssert tup is tuple
  556. doAssert tup[0] is tuple
  557. for ai in tup.fields:
  558. doAssert ai is tuple, "BUG2"
  559. # const c=(foo:(bar1: 0.0))
  560. const c=(foo:(bar1:"foo1"))
  561. fun2(c)
  562. block: # bug #21708
  563. type
  564. Tup = tuple[name: string]
  565. const X: array[2, Tup] = [(name: "foo",), (name: "bar",)]
  566. static:
  567. let s = X[0]
  568. doAssert s[0] == "foo"
  569. block:
  570. proc swap[T](x: var T): T =
  571. result = x
  572. x = default(T)
  573. proc merge[T](a, b: var openArray[T]) =
  574. a[0] = swap b[0]
  575. static:
  576. var x = "abc"
  577. var y = "356"
  578. merge(x, y)
  579. doAssert x == "3bc"
  580. block: # bug #22190
  581. type
  582. EVMFork = enum
  583. Berlin
  584. Istanbul
  585. Shanghai
  586. const
  587. Vm2OpAllForks =
  588. {EVMFork.low .. EVMFork.high}
  589. vm2OpExecBlockData = [(forks: Vm2OpAllForks)]
  590. proc mkOpTable(selected: EVMFork): bool =
  591. selected notin vm2OpExecBlockData[0].forks
  592. const
  593. tab = mkOpTable(Berlin)
  594. doAssert not tab
  595. block: # issue #22524
  596. const cnst = cstring(nil)
  597. doAssert cnst.isNil
  598. doAssert cnst == nil
  599. let b = cnst
  600. doAssert b.isNil
  601. doAssert b == nil
  602. let a = static: cstring(nil)
  603. doAssert a.isNil
  604. static:
  605. var x: cstring
  606. doAssert x.isNil
  607. doAssert x == nil
  608. doAssert x != ""
  609. block: # issue #15730
  610. const s: cstring = ""
  611. doAssert s != nil
  612. static:
  613. let s: cstring = ""
  614. doAssert not s.isNil
  615. doAssert s != nil
  616. doAssert s == ""
  617. static: # more nil cstring issues
  618. let x = cstring(nil)
  619. doAssert x.len == 0
  620. block: # bug #23925
  621. type Foo = enum A = -1
  622. proc foo =
  623. doAssert cast[Foo](-1) == A
  624. doAssert ord(A) == -1
  625. static: foo()
  626. foo()
  627. type E = enum
  628. e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20
  629. e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38
  630. e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50 e51 e52 e53 e54 e55 e56
  631. e57 e58 e59 e60 e61 e62 e63 e64 e65 e66 e67 e68 e69 e70 e71 e72 e73 e74
  632. e75 e76 e77 e78 e79 e80 e81 e82 e83 e84 e85 e86 e87 e88 e89 e90 e91 e92
  633. e93 e94 e95 e96 e97 e98 e99 e100 e101 e102 e103 e104 e105 e106 e107 e108
  634. e109 e110 e111 e112 e113 e114 e115 e116 e117 e118 e119 e120 e121 e122
  635. e123 e124 e125 e126 e127 e128
  636. proc bar =
  637. doAssert cast[E](int(e128)) == e128
  638. static: bar()
  639. bar()
  640. static: # bug #21353
  641. var s: proc () = default(proc ())
  642. doAssert s == nil