# # # The Nim Compiler # (c) Copyright 2020 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. # ## This module contains 'typeAllowed' and friends which check ## for invalid types like 'openArray[var int]'. import intsets, ast, renderer, options, semdata, types when defined(nimPreviewSlimSystem): import std/assertions type TTypeAllowedFlag* = enum taField, taHeap, taConcept, taIsOpenArray, taNoUntyped taIsTemplateOrMacro taProcContextIsNotMacro TTypeAllowedFlags* = set[TTypeAllowedFlag] proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind; c: PContext; flags: TTypeAllowedFlags = {}): PType proc typeAllowedNode(marker: var IntSet, n: PNode, kind: TSymKind, c: PContext; flags: TTypeAllowedFlags = {}): PType = if n != nil: result = typeAllowedAux(marker, n.typ, kind, c, flags) if result == nil: case n.kind of nkNone..nkNilLit: discard else: #if n.kind == nkRecCase and kind in {skProc, skFunc, skConst}: # return n[0].typ for i in 0.. 0: result = classifyViewTypeAux(marker, lastSon(t)) else: result = noView of tyTuple: result = noView for i in 0..