File: tqualifiedtype.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (25 lines) | stat: -rw-r--r-- 957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# issue #19866

# Switch module import order to switch which of last two
# doAsserts fails
import mqualifiedtype1
import mqualifiedtype2

# this isn't officially supported but needed to point out the issue:
template f(moduleName: untyped): int = sizeof(`moduleName`.A)
template g(someType:   untyped): int = sizeof(someType)

# These are legitimately true.
doAssert sizeof(mqualifiedtype1.A) != sizeof(mqualifiedtype2.A)
doAssert g(mqualifiedtype1.A) != g(mqualifiedtype2.A)

# Which means that this should not be true, but is in Nim 1.6
doAssert f(`mqualifiedtype1`) != f(`mqualifiedtype2`)
doAssert f(mqualifiedtype1) != f(mqualifiedtype2)

# These should be true, but depending on import order, exactly one
# fails in Nim 1.2, 1.6 and devel.
doAssert f(`mqualifiedtype1`) == g(mqualifiedtype1.A)
doAssert f(`mqualifiedtype2`) == g(mqualifiedtype2.A)
doAssert f(mqualifiedtype1) == g(mqualifiedtype1.A)
doAssert f(mqualifiedtype2) == g(mqualifiedtype2.A)