@@ -97,12 +97,7 @@ proc doImports(c: var SemContext; files: seq[ImportedFilename]; mode: ImportFilt
9797 for f in files:
9898 importSingleFileConsiderExports c, f, origin, mode, info
9999
100- proc semImport (c: var SemContext ; it: var Item ) =
101- let info = it.n.info
102- var x = it.n
103- skip it.n
104- inc x # skip the `import`
105-
100+ template maybeCyclic (c: var SemContext ; x: var Cursor ) =
106101 if x.kind == ParLe and x.exprKind == PragmaxX :
107102 inc x
108103 var y = x
@@ -113,6 +108,13 @@ proc semImport(c: var SemContext; it: var Item) =
113108 cyclicImport (c, x)
114109 return
115110
111+ proc semImport (c: var SemContext ; it: var Item ) =
112+ let info = it.n.info
113+ var x = it.n
114+ skip it.n
115+ inc x # skip the `import`
116+ maybeCyclic (c, x)
117+
116118 var files: seq [ImportedFilename ] = @ []
117119 var hasError = false
118120 while x.kind != ParRi :
@@ -130,15 +132,7 @@ proc semImportExcept(c: var SemContext; it: var Item) =
130132 skip it.n
131133 inc x # skip the `importexcept`
132134
133- if x.kind == ParLe and x.exprKind == PragmaxX :
134- inc x
135- var y = x
136- skip y
137- if y.substructureKind == PragmasU :
138- inc y
139- if y.kind == Ident and pool.strings[y.litId] == " cyclic" :
140- cyclicImport (c, x)
141- return
135+ maybeCyclic (c, x)
142136
143137 var files: seq [ImportedFilename ] = @ []
144138 var hasError = false
@@ -159,15 +153,7 @@ proc semFromImport(c: var SemContext; it: var Item) =
159153 skip it.n
160154 inc x # skip the `from`
161155
162- if x.kind == ParLe and x.exprKind == PragmaxX :
163- inc x
164- var y = x
165- skip y
166- if y.substructureKind == PragmasU :
167- inc y
168- if y.kind == Ident and pool.strings[y.litId] == " cyclic" :
169- cyclicImport (c, x)
170- return
156+ maybeCyclic (c, x)
171157
172158 var files: seq [ImportedFilename ] = @ []
173159 var hasError = false
0 commit comments