-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[superseded] simplify code that handles hints/warnings #10063
Conversation
28f668b
to
bf1c539
Compare
Hmm, I am not convinced that this is any better or worse. It is just different. |
I don't think it's good style to have to write stuff like this:
which is completely redundant / DRY violation of the corresponding enum members; my PR gets rid of it and computes these automatically (and simplifies code that gets human string from enum) |
Regardless of whether your chances are good or bad, this is just not true. These names are exposed to the command line so any internal compiler renaming would influence Nim's command line syntax. |
bf1c539
to
03f12e1
Compare
but there are only 4 exceptions out of 60 names (hints/warnings), which I cleanly handle in proc msgToHumanStr*(a: TMsgKind): string =
case a # handle exceptions here
of warnInconsistentSpacing: result = "Spacing"
of hintConditionAlwaysTrue: result = "CondTrue"
of hintConditionAlwaysFalse: result = "CondFalse"
of hintExecuting: result = "Exec"
of hintLinking: result = "Link"
else: # general case
case a
of warnMin..warnMax: result = ($a)["warn".len .. ^1]
of hintMin..hintMax: result = ($a)["hint".len .. ^1]
else: doAssert false IMO it's cleaner to handle the general case (allowing for the occasional, rare exception) rather than duplicating the enum names in WarningsToStr, HintsToStr. |
03f12e1
to
f6a972b
Compare
/cc @Araq tests are green |
ping @Araq |
I like the old version better and objectively your code adds new imports / dependencies that the old variant didn't have. |
removing the TODO; this has since been more or less implemented via #15775 and hint:link + --listcmd for the 2 aspects of this PR |
proc msgToHumanStr*(a: TMsgKind): string
. This simplifies a bunch of code related to hints/warningshintLinkingVerbose
to always show link command; happy to make that the new meaning forhintLink
if we don't want to create a new hint for that (the existinghintLink
isn't very useful as it doesn't show anything except "Link")note
I could also use an inverted index table, eg:
however,
humanStrToMsg
is only used in non performance critical places so I went for simplicity instead (with same time complexity as before PR)