Skip to content

Commit

Permalink
follow suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Oct 4, 2023
1 parent 0add81e commit bc3b9cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions compiler/front/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -664,23 +664,33 @@ template globalReport*(conf: ConfigRef, report: ReportTypes) =
handleReport(
conf, wrap(report, instLoc()), instLoc(), doRaise)

proc reportAndForceRaise*(
proc reportAndFail*(
conf: ConfigRef, r: Report, reportFrom: InstantiationInfo) =
## Similar to `handleReport`, but, unless overridden with aborting
## (`doAbort`) by the structured report hook, always raises a recoverable
## error.
var rep = r
fillReportAndHandleVmTrace(conf, rep, reportFrom)

case conf.report(rep)
let userAction = conf.report(rep)
case userAction
of doAbort:
quit 1
of doRaise, doDefault, doNothing:
of doDefault:
let (action, trace) = errorActions(conf, rep, userAction)
case action
of doAbort:
quit 1
of doRaise, doNothing:
raiseRecoverableError("report")
of doDefault:
unreachable()
of doRaise, doNothing:
raiseRecoverableError("report")

template reportAndForceRaise*(
template reportAndFail*(
conf: ConfigRef; info: TLineInfo, report: ReportTypes) =
reportAndForceRaise(
reportAndFail(
conf, wrap(report, instLoc(), info), instLoc())

template localReport*(conf: ConfigRef; info: TLineInfo, report: ReportTypes) =
Expand Down
4 changes: 2 additions & 2 deletions compiler/sem/semdata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1065,13 +1065,13 @@ proc markIndirect*(c: PContext, s: PSym) {.inline.} =

proc checkSonsLen*(n: PNode, length: int; conf: ConfigRef) =
if n.len != length:
conf.reportAndForceRaise(n.info, reportAst(
conf.reportAndFail(n.info, reportAst(
rsemIllformedAst, n,
str = "Expected $1 elements, but found $2" % [$length, $n.len]))

proc checkMinSonsLen*(n: PNode, length: int; conf: ConfigRef) =
if n.len < length:
conf.reportAndForceRaise(n.info, reportAst(
conf.reportAndFail(n.info, reportAst(
rsemIllformedAst, n,
str = "Expected at least $1 elements, but found $2" % [$length, $n.len]))

Expand Down

0 comments on commit bc3b9cb

Please sign in to comment.