diff options
author | Matthew Baulch <baulch.matt@gmail.com> | 2016-08-11 21:13:18 +1000 |
---|---|---|
committer | Matthew Baulch <baulch.matt@gmail.com> | 2016-08-11 21:13:18 +1000 |
commit | 674a1110f0ad8b95bb6d7332c87aa1c684cd0973 (patch) | |
tree | 85d8d015f6cb655cb8fc384031eef555d7b11c1a /compiler/semmagic.nim | |
parent | 8ebce3ce2b4210125bc8bf16aba1323d719adaf7 (diff) | |
download | Nim-674a1110f0ad8b95bb6d7332c87aa1c684cd0973.tar.gz |
Require ordinal or set argument to system.ord
Diffstat (limited to 'compiler/semmagic.nim')
-rw-r--r-- | compiler/semmagic.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index d9fec6275..cbe9bc176 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -114,8 +114,12 @@ proc semTypeTraits(c: PContext, n: PNode): PNode = proc semOrd(c: PContext, n: PNode): PNode = result = n - result.typ = makeRangeType(c, firstOrd(n.sons[1].typ), - lastOrd(n.sons[1].typ), n.info) + let parType = n.sons[1].typ + if isOrdinalType(parType) or parType.kind == tySet: + result.typ = makeRangeType(c, firstOrd(parType), lastOrd(parType), n.info) + else: + localError(n.info, errOrdinalTypeExpected) + result.typ = errorType(c) proc semBindSym(c: PContext, n: PNode): PNode = result = copyNode(n) |