Skip to content

Commit d136af0

Browse files
authored
modernize lineinfos; it seems that array access hinders strict def analysis like field access (#22420)
modernize lineinfos; array access hinders strict def analysis like field access A bug ? ```nim proc computeNotesVerbosity(): array[0..3, TNoteKinds] = result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores, warnResultUsed, warnAnyEnumConv, warnBareExcept} result[2] = result[3] - {hintStackTrace, hintExtendedContext, hintDeclaredLoc, hintProcessingStmt} result[1] = result[2] - {warnProveField, warnProveIndex, warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd, hintSource, hintGlobalVar, hintGCStats, hintMsgOrigin, hintPerformance} result[0] = result[1] - {hintSuccessX, hintSuccess, hintConf, hintProcessing, hintPattern, hintExecuting, hintLinking, hintCC} ```
1 parent 73e661d commit d136af0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

compiler/lineinfos.nim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# distribution, for details about the copyright.
88
#
99

10-
## This module contains the ``TMsgKind`` enum as well as the
11-
## ``TLineInfo`` object.
10+
## This module contains the `TMsgKind` enum as well as the
11+
## `TLineInfo` object.
1212

1313
import ropes, tables, pathutils, hashes
1414

@@ -248,6 +248,7 @@ type
248248
TNoteKinds* = set[TNoteKind]
249249

250250
proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
251+
result = default(array[0..3, TNoteKinds])
251252
result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores, warnResultUsed, warnAnyEnumConv, warnBareExcept}
252253
result[2] = result[3] - {hintStackTrace, hintExtendedContext, hintDeclaredLoc, hintProcessingStmt}
253254
result[1] = result[2] - {warnProveField, warnProveIndex,
@@ -341,9 +342,8 @@ type
341342

342343

343344
proc initMsgConfig*(): MsgConfig =
344-
result.msgContext = @[]
345-
result.lastError = unknownLineInfo
346-
result.filenameToIndexTbl = initTable[string, FileIndex]()
347-
result.fileInfos = @[]
348-
result.errorOutputs = {eStdOut, eStdErr}
345+
result = MsgConfig(msgContext: @[], lastError: unknownLineInfo,
346+
filenameToIndexTbl: initTable[string, FileIndex](),
347+
fileInfos: @[], errorOutputs: {eStdOut, eStdErr}
348+
)
349349
result.filenameToIndexTbl["???"] = FileIndex(-1)

0 commit comments

Comments
 (0)