Move `compiles` back

This commit is contained in:
Anatoly Galiulin 2016-03-31 16:45:54 +06:00
commit a9330391c3

View file

@ -2561,16 +2561,6 @@ else:
if x < 0: -x else: x if x < 0: -x else: x
{.pop.} {.pop.}
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect, compileTime.} =
## Special compile-time procedure that checks whether `x` can be compiled
## without any semantic error.
## This can be used to check whether a type supports some operation:
##
## .. code-block:: Nim
## when not compiles(3 + 4):
## echo "'+' for integers is available"
discard
when not defined(JS): #and not defined(nimscript): when not defined(JS): #and not defined(nimscript):
{.push stack_trace: off, profiler:off.} {.push stack_trace: off, profiler:off.}
@ -3480,6 +3470,16 @@ when hasAlloc:
x[j+i] = item[j] x[j+i] = item[j]
inc(j) inc(j)
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect, compileTime.} =
## Special compile-time procedure that checks whether `x` can be compiled
## without any semantic error.
## This can be used to check whether a type supports some operation:
##
## .. code-block:: Nim
## when not compiles(3 + 4):
## echo "'+' for integers is available"
discard
when declared(initDebugger): when declared(initDebugger):
initDebugger() initDebugger()