Nim/tests/pragmas/treorder.nim
ringabout 38f876dd48
fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now parses the whole module at one time (#21379)
* fixes #19795; remove parse pipeline

* isScript

* fixes nimscriptapi

* don't touch reorder

* check script

* fixes tests

* it seems implicit imports of system cause troubles

* access the first child of `nkStmtList`

* ignore comments

* minor messages

* perhaps increases hloLoopDetector

* the module is a stmtList, which changes the errors

* fixes nimdoc

* fixes tlinter

* fixes nim  secret tests

* fixes arc_misc

* fixes nim secret tests again

* safe; fixes one more test

* GlobalError is the root cause too

* fixes parsing errors

* put emit types to the cfsForwardTypes section

* fixes #11852; `{.push checks:off}` now works in procs

* disable navigator

* fixes nimdoc

* add tests for JS

* fixes nimsuggest
2023-02-22 20:34:20 +01:00

76 lines
979 B
Nim

discard """
matrix: "--experimental:codeReordering"
output:'''0
1
2
3'''
"""
import macros
# {.reorder: on .}
{.experimental: "codeReordering".}
echo foo(-1)
echo callWithFoo(0)
echo(CA+CD)
echo useTypes(TA(x:TB(x:1)), 2)
second(0)
template callWithFoo(arg: untyped): untyped =
foo(arg)
proc first(i: int): void
proc second(i: int): void =
make(first)
first(i)
proc useTypes(a: TA, d: TD): int =
result = a.x.x+d
type
TDoubleCyclic = ref object
x: TCyclicA
y: TCyclicB
type
TCyclicA = ref object
x: TDoubleCyclic
type
TCyclicB = ref object
x: TDoubleCyclic
const
CA = 1
CB = CC
type
TA = object
x: TB
TC = type(CC)
TD = type(CA)
const
CC = 1
CD = CB
type
TB = object
x: TC
proc foo(x: int): int =
result = bar(x)
proc bar(x: int): int =
result = x+1
macro make(arg: untyped): untyped =
ss &= arg.repr
ss &= " "
discard
proc first(i: int): void =
make(second)
var ss {.compileTime.}: string = ""