From 8c211113f26260896614b7385b94ed91a5b9f291 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 31 May 2013 01:27:03 +0200 Subject: better error message for subtle nil errors --- compiler/cgen.nim | 2 ++ compiler/options.nim | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 92216d278..7e782fc12 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -346,6 +346,8 @@ proc resetLoc(p: BProc, loc: var TLoc) = else: linefmt(p, cpsStmts, "$1 = 0;$n", rdLoc(loc)) else: + if optNilCheck in p.options: + linefmt(p, cpsStmts, "#chckNil((void*)$1);$n", addrLoc(loc)) if loc.s != OnStack: linefmt(p, cpsStmts, "#genericReset((void*)$1, $2);$n", addrLoc(loc), genTypeInfo(p.module, loc.t)) diff --git a/compiler/options.nim b/compiler/options.nim index f67ded163..6d93048fe 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -92,7 +92,7 @@ var gOptions*: TOptions = {optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck, optOverflowCheck, optAssert, optWarns, optHints, optStackTrace, optLineTrace, - optPatterns} + optPatterns, optNilCheck} gGlobalOptions*: TGlobalOptions = {optThreadAnalysis} gExitcode*: int8 gCmd*: TCommands = cmdNone # the command -- cgit 1.4.1-2-gfad0