Of operator in vm fixes [backport] (#9717)
* fixes #9701 * fixes #9702 * optimize of statement to bool
This commit is contained in:
parent
2104863910
commit
8c1083d3b7
6 changed files with 65 additions and 7 deletions
|
|
@ -306,7 +306,13 @@ proc semOf(c: PContext, n: PNode): PNode =
|
|||
result.typ = getSysType(c.graph, n.info, tyBool)
|
||||
return result
|
||||
elif diff == high(int):
|
||||
localError(c.config, n.info, "'$1' cannot be of this subtype" % typeToString(a))
|
||||
if commonSuperclass(a, b) == nil:
|
||||
localError(c.config, n.info, "'$1' cannot be of this subtype" % typeToString(a))
|
||||
else:
|
||||
message(c.config, n.info, hintConditionAlwaysFalse, renderTree(n))
|
||||
result = newIntNode(nkIntLit, 0)
|
||||
result.info = n.info
|
||||
result.typ = getSysType(c.graph, n.info, tyBool)
|
||||
else:
|
||||
localError(c.config, n.info, "'of' takes 2 arguments")
|
||||
n.typ = getSysType(c.graph, n.info, tyBool)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue