fix #18886 crash on ambiguous proc cast (#20472)

* fix #18886 crash on ambiguous proc cast

* follow suggestion
This commit is contained in:
Bung 2022-10-10 17:09:54 +08:00 • committed by GitHub
commit db3d2971cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View file

@ -371,6 +371,8 @@ proc semCast(c: PContext, n: PNode): PNode =
checkSonsLen(n, 2, c.config)
let targetType = semTypeNode(c, n[0], nil)
let castedExpr = semExprWithType(c, n[1])
if castedExpr.kind == nkClosedSymChoice:
errorUseQualifier(c, n[1].info, castedExpr)
if tfHasMeta in targetType.flags:
localError(c.config, n[0].info, "cannot cast to a non concrete type: '$1'" % $targetType)
if not isCastable(c, targetType, castedExpr.typ, n.info):