Skip to content

Instantly share code, notes, and snippets.

@barcharcraz
Last active August 29, 2015 13:57
Show Gist options
  • Save barcharcraz/6b9bcfc874334de2c914 to your computer and use it in GitHub Desktop.
Save barcharcraz/6b9bcfc874334de2c914 to your computer and use it in GitHub Desktop.
should it comple?
import macros
type int1 = distinct int
type int2 = distinct int
proc take[T](value: int1) =
when T is int2:
static: error("killed in take(int1)")
proc take[T](vale: int2) =
when T is int1:
static: error("killed in take(int2)")
var i1: int1 = 1.int1
var i2: int2 = 2.int2
static: hint("compile take[int1](i1)")
take[int1](i1)
static: hint("compile take[int2](i2)")
take[int2](i2)
fails with error
overload.nim(13, 12) Hint: compile take[int1](i1) [User]
stack trace: (most recent call last)
overload.nim(9) take
overload.nim(14, 4) Info: instantiation from here
overload.nim(9, 17) Error: killed in take(int2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment