From daaf50ae0383e4b8250cfca7cfe3cee27a0290d9 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 9 Dec 2018 19:11:08 -0800 Subject: refs #9906; --errorMax:10 allows stopping after 10 errors --- compiler/commands.nim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index fa17e9851..576a7dc7f 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -617,6 +617,11 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "run", "r": expectNoArg(conf, switch, arg, pass, info) incl(conf.globalOptions, optRun) + of "errormax": + # Note: `nim check` (etc) can overwrite this; + # `0` is meaningless and has same effect as `1` + expectArg(conf, switch, arg, pass, info) + conf.errorMax = parseInt(arg) of "verbosity": expectArg(conf, switch, arg, pass, info) let verbosity = parseInt(arg) -- cgit 1.4.1-2-gfad0 From 9d10278a9ca0d90a5fe82fa6e7dfb7d7dcb0f38a Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 9 Dec 2018 23:39:57 -0800 Subject: --errorMax:0 means: unlimited --- compiler/commands.nim | 10 +++++++--- doc/advopt.txt | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index 576a7dc7f..40283489c 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -618,10 +618,14 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; expectNoArg(conf, switch, arg, pass, info) incl(conf.globalOptions, optRun) of "errormax": - # Note: `nim check` (etc) can overwrite this; - # `0` is meaningless and has same effect as `1` expectArg(conf, switch, arg, pass, info) - conf.errorMax = parseInt(arg) + conf.errorMax = block: + # Note: `nim check` (etc) can overwrite this. + # `0` is meaningless, give it a useful meaning as in clang's -ferror-limit + # If user doesn't set this flag and the code doesn't either, it'd + # have the same effect as errorMax = 1 + let ret = parseInt(arg) + if ret == 0: high(int) else: ret of "verbosity": expectArg(conf, switch, arg, pass, info) let verbosity = parseInt(arg) diff --git a/doc/advopt.txt b/doc/advopt.txt index 11af58392..eca7b0a08 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -103,7 +103,7 @@ Advanced options: value = number of processors (0 for auto-detect) --incremental:on|off only recompile the changed modules (experimental!) --verbosity:0|1|2|3 set Nim's verbosity level (1 is default) - --errorMax:int stop after n (>=1) errors in semantic pass + --errorMax:int stop after n errors in semantic pass; 0 means unlimited --experimental:$1 enable experimental language feature -v, --version show detailed version information -- cgit 1.4.1-2-gfad0 From 5ffa9a8be643711662856334ff3d98ee68c85e2d Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 9 Dec 2018 09:20:59 +0100 Subject: destructors: defensive programming against wrong generated destructor for string/seq --- compiler/commands.nim | 2 +- compiler/semasgn.nim | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index fa17e9851..b5bcfabc5 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -480,7 +480,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "native", "gdb": incl(conf.globalOptions, optCDebug) conf.options = conf.options + {optLineDir} - {optEndb} - defineSymbol(conf.symbols, "nimTypeNames") # type names are used in gdb pretty printing + #defineSymbol(conf.symbols, "nimTypeNames") # type names are used in gdb pretty printing undefSymbol(conf.symbols, "endb") else: localError(conf, info, "expected endb|gdb but found " & arg) diff --git a/compiler/semasgn.nim b/compiler/semasgn.nim index 3947e4f6c..5d676dc76 100644 --- a/compiler/semasgn.nim +++ b/compiler/semasgn.nim @@ -309,11 +309,15 @@ proc liftBody(c: PContext; typ: PType; kind: TTypeAttachedOp; liftBodyAux(a, typ, body, newSymNode(dest).newDeref, newSymNode(src)) # recursion is handled explicitly, do not register the type based operation # before 'liftBodyAux': - case kind - of attachedAsgn: typ.assignment = result - of attachedSink: typ.sink = result - of attachedDeepCopy: typ.deepCopy = result - of attachedDestructor: typ.destructor = result + if c.config.selectedGC == gcDestructors and + typ.kind in {tySequence, tyString} and body.len == 0: + discard "do not cache it yet" + else: + case kind + of attachedAsgn: typ.assignment = result + of attachedSink: typ.sink = result + of attachedDeepCopy: typ.deepCopy = result + of attachedDestructor: typ.destructor = result var n = newNodeI(nkProcDef, info, bodyPos+1) for i in 0 ..< n.len: n.sons[i] = newNodeI(nkEmpty, info) -- cgit 1.4.1-2-gfad0 From c682671feae3ae6c90416152f84b274cb5aa4a21 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 11 Dec 2018 23:07:36 +0100 Subject: minor cleanups --- compiler/commands.nim | 13 ++++++------- doc/advopt.txt | 2 +- doc/contributing.rst | 11 +---------- 3 files changed, 8 insertions(+), 18 deletions(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index b962e8f39..b090a09a5 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -619,13 +619,12 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; incl(conf.globalOptions, optRun) of "errormax": expectArg(conf, switch, arg, pass, info) - conf.errorMax = block: - # Note: `nim check` (etc) can overwrite this. - # `0` is meaningless, give it a useful meaning as in clang's -ferror-limit - # If user doesn't set this flag and the code doesn't either, it'd - # have the same effect as errorMax = 1 - let ret = parseInt(arg) - if ret == 0: high(int) else: ret + # Note: `nim check` (etc) can overwrite this. + # `0` is meaningless, give it a useful meaning as in clang's -ferror-limit + # If user doesn't set this flag and the code doesn't either, it'd + # have the same effect as errorMax = 1 + let ret = parseInt(arg) + conf.errorMax = if ret == 0: high(int) else: ret of "verbosity": expectArg(conf, switch, arg, pass, info) let verbosity = parseInt(arg) diff --git a/doc/advopt.txt b/doc/advopt.txt index baab4f6e5..7446775db 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -104,7 +104,7 @@ Advanced options: value = number of processors (0 for auto-detect) --incremental:on|off only recompile the changed modules (experimental!) --verbosity:0|1|2|3 set Nim's verbosity level (1 is default) - --errorMax:int stop after n errors in semantic pass; 0 means unlimited + --errorMax:N stop compilation after N errors; 0 means unlimited --experimental:$1 enable experimental language feature -v, --version show detailed version information diff --git a/doc/contributing.rst b/doc/contributing.rst index a2c95db74..e3ab697d3 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -263,17 +263,8 @@ Take advantage of no implicit bool conversion doAssert isValid() == true doAssert isValid() # preferred -.. _immediately_invoked_lambdas: -Immediately invoked lambdas (https://en.wikipedia.org/wiki/Immediately-invoked_function_expression) - -.. code-block:: nim - - let a = (proc (): auto = getFoo())() - let a = block: # preferred - getFoo() - .. _design_for_mcs: -Design with method call syntax (UFCS in other languages) chaining in mind +Design with method call syntax chaining in mind .. code-block:: nim -- cgit 1.4.1-2-gfad0