Skip to content

Commit b47747d

Browse files
authored
[backport v2.0] Converted the 'invalid kind for firstOrd/lastOrd(XXX)' messages from internal errors to fatal errors. (#23443) (#23446)
This fixes a nimsuggest crash when opening: beacon_chain/consensus_object_pools/blockchain_dag.nim from the nimbus-eth2 project and many other .nim files (44 files, to be precise) in the same project. Replaces: #23402 (cherry picked from commit c934d59)
1 parent 5667fbf commit b47747d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/types.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,11 @@ proc firstOrd*(conf: ConfigRef; t: PType): Int128 =
838838
result = firstOrd(conf, lastSon(t))
839839
of tyOrdinal:
840840
if t.len > 0: result = firstOrd(conf, lastSon(t))
841-
else: internalError(conf, "invalid kind for firstOrd(" & $t.kind & ')')
841+
else: fatal(conf, unknownLineInfo, "invalid kind for firstOrd(" & $t.kind & ')')
842842
of tyUncheckedArray, tyCstring:
843843
result = Zero
844844
else:
845-
internalError(conf, "invalid kind for firstOrd(" & $t.kind & ')')
845+
fatal(conf, unknownLineInfo, "invalid kind for firstOrd(" & $t.kind & ')')
846846
result = Zero
847847

848848
proc firstFloat*(t: PType): BiggestFloat =
@@ -926,11 +926,11 @@ proc lastOrd*(conf: ConfigRef; t: PType): Int128 =
926926
of tyProxy: result = Zero
927927
of tyOrdinal:
928928
if t.len > 0: result = lastOrd(conf, lastSon(t))
929-
else: internalError(conf, "invalid kind for lastOrd(" & $t.kind & ')')
929+
else: fatal(conf, unknownLineInfo, "invalid kind for lastOrd(" & $t.kind & ')')
930930
of tyUncheckedArray:
931931
result = Zero
932932
else:
933-
internalError(conf, "invalid kind for lastOrd(" & $t.kind & ')')
933+
fatal(conf, unknownLineInfo, "invalid kind for lastOrd(" & $t.kind & ')')
934934
result = Zero
935935

936936
proc lastFloat*(t: PType): BiggestFloat =

0 commit comments

Comments
 (0)