summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/rodread.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rodread.nim b/compiler/rodread.nim
index 92ce00240..e4530c2cc 100644
--- a/compiler/rodread.nim
+++ b/compiler/rodread.nim
@@ -898,6 +898,8 @@ proc getBody*(s: PSym): PNode =
   ## it may perform an expensive reload operation. Otherwise it's a simple
   ## accessor.
   assert s.kind in routineKinds
+  # prevent crashes due to incorrect macro transformations (bug #2377)
+  if s.ast.isNil or bodyPos >= s.ast.len: return ast.emptyNode
   result = s.ast.sons[bodyPos]
   if result == nil:
     assert s.offset != 0