Skip to content

Commit b68c1e3

Browse files
authored
replaces raiseAssert with bugs in nimony + hexer (#1091)
ref #1066
1 parent 7b1fe38 commit b68c1e3

18 files changed

+51
-51
lines changed

src/hexer/constparams.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ proc trPragmaBlock(c: var Context; dest: var TokenBuf; n: var Cursor) =
301301
tr(c, dest, n)
302302
c.keepOverflowFlag = oldKeepOverflowFlag
303303
else:
304-
raiseAssert "unknown pragma block: " & toString(n, false)
304+
bug "unknown pragma block: " & toString(n, false)
305305
skipParRi n # pragmax
306306

307307
proc checkedArithOp(c: var Context; dest: var TokenBuf; n: var Cursor) =

src/hexer/destroyer.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ proc leaveNamedBlock(c: var Context; label: SymId) =
152152
if it != nil and it.label == label:
153153
leaveScope(c, it[])
154154
else:
155-
raiseAssert "do not know which block to leave"
155+
bug "do not know which block to leave"
156156

157157
proc leaveAnonBlock(c: var Context) =
158158
var it = addr(c.currentScope)
@@ -162,7 +162,7 @@ proc leaveAnonBlock(c: var Context) =
162162
if it != nil and it.kind == WhileOrBlock:
163163
leaveScope(c, it[])
164164
else:
165-
raiseAssert "do not know which block to leave"
165+
bug "do not know which block to leave"
166166

167167
proc trBreak(c: var Context; n: var Cursor) =
168168
let lab = n.firstSon

src/hexer/desugar.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ proc skipParRi(n: var Cursor) =
6565
if n.kind == ParRi:
6666
inc n
6767
else:
68-
error "expected ')', but got: ", n
68+
bug "expected ')', but got: ", n
6969

7070
proc tr(c: var Context; dest: var TokenBuf; n: var Cursor)
7171

@@ -318,7 +318,7 @@ proc genSetOp(c: var Context; dest: var TokenBuf; n: var Cursor) =
318318
dest.addUIntLit(uint64(mask), info)
319319
dest.addUIntLit(0, info)
320320
else:
321-
raiseAssert("unreachable")
321+
bug("unreachable")
322322
else:
323323
case kind
324324
of LtSetX, LeSetX:
@@ -387,7 +387,7 @@ proc genSetOp(c: var Context; dest: var TokenBuf; n: var Cursor) =
387387
of PlusSetX: BitorX
388388
of XorSetX: BitxorX
389389
of MulSetX, MinusSetX: BitandX
390-
else: raiseAssert("unreachable")
390+
else: bug("unreachable")
391391
addUIntTypedOp dest, op, 8, info:
392392
copyIntoKind dest, ArrAtX, info:
393393
dest.addSubtree a
@@ -418,7 +418,7 @@ proc genSetOp(c: var Context; dest: var TokenBuf; n: var Cursor) =
418418
dest.addUIntLit(7, info)
419419
dest.addUIntLit(0, info)
420420
else:
421-
raiseAssert("unreachable")
421+
bug("unreachable")
422422
if useTemp:
423423
dest.addParRi()
424424
c.tempUseBufStack.shrink(oldBufStackLen)
@@ -767,7 +767,7 @@ proc tr(c: var Context; dest: var TokenBuf; n: var Cursor) =
767767
else:
768768
trSons(c, dest, n)
769769
of ParRi:
770-
raiseAssert "unexpected ')' inside"
770+
bug "unexpected ')' inside"
771771

772772
proc desugar*(n: Cursor; moduleSuffix: string; activeChecks: set[CheckMode]): TokenBuf =
773773
var c = Context(counter: 0, typeCache: createTypeCache(), thisModuleSuffix: moduleSuffix, activeChecks: activeChecks)

src/hexer/duplifier.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,9 @@ proc tr(c: var Context; n: var Cursor; e: Expects) =
927927
of DerefX, HderefX:
928928
trDeref c, n
929929
of DdotX:
930-
raiseAssert "nodekind should have been eliminated in desugar.nim"
930+
bug "nodekind should have been eliminated in desugar.nim"
931931
of DefaultobjX, DefaulttupX, BracketX, CurlyX, TupX:
932-
raiseAssert "nodekind should have been eliminated in sem.nim"
932+
bug "nodekind should have been eliminated in sem.nim"
933933
of PragmaxX, CurlyatX, TabconstrX, DoX, FailedX:
934934
trSons c, n, e
935935
of NoExpr:

src/hexer/inliner.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ proc inlineRoutineBody(c: var InlineContext; dest: var TokenBuf; n: var Cursor)
157157
dest.add n
158158
inc n
159159
of ParRi:
160-
raiseAssert "unhandled ')' in inliner.nim"
160+
bug "unhandled ')' in inliner.nim"
161161
of ParLe:
162162
case n.stmtKind
163163
of RetS:

src/hexer/lifter.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ proc isTrivial*(c: var LiftingCtx; typ: TypeCursor): bool =
141141
result = true
142142
of NoType, ErrT, NiltT, OrT, AndT, NotT, ConceptT, DistinctT, StaticT, InvokeT,
143143
TypeKindT, UntypedT, TypedT, IteratorT, ItertypeT:
144-
raiseAssert "bug here"
144+
bug "bug here"
145145

146146
# Phase 2: Do the lifting
147147

@@ -220,7 +220,7 @@ proc lift(c: var LiftingCtx; typ: TypeCursor): SymId =
220220
let typ = toTypeImpl typ
221221
case typ.typeKind
222222
of PtrT:
223-
raiseAssert "ptr T should have been a 'trivial' type"
223+
bug "ptr T should have been a 'trivial' type"
224224
of ObjectT, DistinctT, TupleT, ArrayT, RefT:
225225
result = requestLifting(c, c.op, orig)
226226
else:

src/hexer/mover.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ proc singlePath(pc: Cursor; nested: int; x: Cursor; pcs: var seq[Cursor]; otherU
150150
pc = pc +! diff
151151
of ParRi:
152152
if nested == 0:
153-
raiseAssert "BUG: unpaired ')'"
153+
bug "unpaired ')'"
154154
dec nested
155155
inc pc
156156
of Symbol:
@@ -219,7 +219,7 @@ proc singlePath(pc: Cursor; nested: int; x: Cursor; pcs: var seq[Cursor]; otherU
219219
IncludeS, ImportS, FromimportS, ImportExceptS, CommentS, PragmasS,
220220
ImportasS, ExportexceptS, BindS, MixinS, UsingS,
221221
UnpackDeclS, StaticstmtS, AsmS, DeferS:
222-
raiseAssert "BUG: statement not eliminated: " & $pc.stmtKind
222+
bug "statement not eliminated: " & $pc.stmtKind
223223
of ProcS, FuncS, IteratorS, ConverterS, MethodS, MacroS, TemplateS, TypeS,
224224
AssumeS, AssertS:
225225
# declarative junk we don't care about:
@@ -283,7 +283,7 @@ when isMainModule:
283283
discard
284284
if nested == 0: break
285285
inc result
286-
raiseAssert "BUG: no 'ensureMove' found"
286+
bug "no 'ensureMove' found"
287287

288288
proc test(s: string; expected: bool) =
289289
var input = parse(s)

src/hexer/nifcgen.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ proc parsePragmas(c: var EContext; n: var Cursor): CollectedPragmas =
716716
skip n
717717
continue
718718
of BuildP, EmitP:
719-
raiseAssert "unreachable"
719+
bug "unreachable"
720720
skipParRi c, n
721721
else:
722722
error c, "unknown pragma: ", n

src/hexer/stringcases.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ proc getSimpleStringLit(c: var EContext; n: var Cursor): StrId =
5252
result = getSimpleStringLit(c, inlineValue)
5353
inc n
5454
else:
55-
raiseAssert "not a string literal"
55+
bug "not a string literal"
5656
else:
5757
case n.exprKind:
5858
of SufX:
@@ -67,7 +67,7 @@ proc getSimpleStringLit(c: var EContext; n: var Cursor): StrId =
6767
result = getSimpleStringLit(c, n)
6868
skipParRi n
6969
else:
70-
raiseAssert "not a string literal"
70+
bug "not a string literal"
7171

7272
proc transformStringCase*(c: var EContext; n: var Cursor) =
7373
c.demand pool.syms.getOrIncl("equalStrings.0." & SystemModuleSuffix)

src/hexer/xelim.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ proc trExpr(c: var Context; dest: var TokenBuf; n: var Cursor; tar: var Target)
452452
while n.kind != ParRi:
453453
trExpr c, dest, n, tar
454454
of ParRi:
455-
raiseAssert "unexpected ')' inside"
455+
bug "unexpected ')' inside"
456456

457457
proc lowerExprs*(n: Cursor; moduleSuffix: string): TokenBuf =
458458
var c = Context(counter: 0, typeCache: createTypeCache(), thisModuleSuffix: moduleSuffix)

0 commit comments

Comments
 (0)