summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index c7e48db4c..12a346f63 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -717,7 +717,11 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
                                           tyUserTypeClassInst})
         if actualType.kind in {tyObject, tyDistinct} and
            actualType.requiresInit:
-          defaultConstructionError(c, v.typ, v.info)
+           # imported type use requiresInit pragma prevent implicit initialization
+          if (tfRequiresInit in actualType.flags and sfImportc in actualType.sym.flags):
+            discard
+          else:
+            defaultConstructionError(c, v.typ, v.info)
         else:
           checkNilable(c, v)
         # allow let to not be initialised if imported from C: