diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 8c5ae8086d..a0378c6f98 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -790,7 +790,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, case typ.kind of shouldChckCovered: chckCovered = true - of tyFloat..tyFloat128, tyError: + of tyError: discard of tyRange: if skipTypes(typ.elementType, abstractInst).kind in shouldChckCovered: @@ -798,7 +798,8 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, of tyForward: errorUndeclaredIdentifier(c, n[0].info, typ.sym.name.s) elif not isOrdinalType(typ): - localError(c.config, n[0].info, "selector must be of an ordinal type, float") + localError(c.config, n[0].info, "selector must be of an ordinal type") + if firstOrd(c.config, typ) != 0: localError(c.config, n.info, "low(" & $a[0].sym.name.s & ") must be 0 for discriminant") diff --git a/tests/errmsgs/tobjectvariants.nim b/tests/errmsgs/tobjectvariants.nim new file mode 100644 index 0000000000..f7084ec51d --- /dev/null +++ b/tests/errmsgs/tobjectvariants.nim @@ -0,0 +1,13 @@ +discard """ + errormsg: "selector must be of an ordinal type" +""" + +type + Case = object + case x: float + of 1.0: + id: int + else: + ta: float + +var s = Case(x: 4.0, id: 1) \ No newline at end of file