catchable defects (#13626)
* allow defects to be caught even for --exceptions:goto (WIP) * implemented the new --panics:on|off switch; refs https://github.com/nim-lang/RFCs/issues/180 * new implementation for integer overflow checking * produce a warning if a user-defined exception type inherits from Exception directly * applied Timothee's suggestions; improved the documentation and replace the term 'checked runtime check' by 'panic' * fixes #13627 * don't inherit from Exception directly
This commit is contained in:
parent
14b2354b7d
commit
a6682de004
35 changed files with 441 additions and 142 deletions
|
|
@ -102,18 +102,20 @@ else:
|
|||
include "system/gc"
|
||||
|
||||
when not declared(nimNewSeqOfCap) and not defined(nimSeqsV2):
|
||||
{.push overflowChecks: on.}
|
||||
proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
|
||||
when defined(gcRegions):
|
||||
let s = mulInt(cap, typ.base.size) # newStr already adds GenericSeqSize
|
||||
let s = cap * typ.base.size # newStr already adds GenericSeqSize
|
||||
result = newStr(typ, s, ntfNoRefs notin typ.base.flags)
|
||||
else:
|
||||
let s = addInt(mulInt(cap, typ.base.size), GenericSeqSize)
|
||||
let s = cap * typ.base.size + GenericSeqSize
|
||||
when declared(newObjNoInit):
|
||||
result = if ntfNoRefs in typ.base.flags: newObjNoInit(typ, s) else: newObj(typ, s)
|
||||
else:
|
||||
result = newObj(typ, s)
|
||||
cast[PGenericSeq](result).len = 0
|
||||
cast[PGenericSeq](result).reserved = cap
|
||||
{.pop.}
|
||||
|
||||
{.pop.}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue