Skip to content
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

limit errors to application source code only and do not check imported packages/std library/etc #21713

Open
noahehall opened this issue Apr 23, 2023 · 3 comments

Comments

@noahehall
Copy link
Contributor

noahehall commented Apr 23, 2023

Summary

i added the switch switch("hintAsError", "XDeclaredButNotUsed:on")
to catch bad practices, however, this also checks nimlangs source which is unexpected

because of this line in lib/system/fatal

 /home/runner/.choosenim/toolchains/nim-1.6.12/lib/system/fatal.nim(13, 9) Error: 'gotoBasedExceptions' is declared but not used [XDeclaredButNotUsed]�
/home/runner/work/nightlies/nightlies/nim-1.6.12/compiler/lookups.nim(299, 12) compiler msg initiated here [MsgOrigin]�

Description

application config switches should not surface errors with conflicting code in nim source, i'm unsure how this occurs - arent I using the compiled nim binary?

[update]

  • added better examples and removed the rest

  • e.g. happens fairly often with Uninit set as error

.choosenim/toolchains/nim-#version-2-0/lib/pure/collections/sequtils.nim(232, 17) 
Error: use explicit initialization of 'result' for clarity [Uninit]�
  • a file with the following code and switch
switch("warningAsError", "ProveInit:on")

import std/sets
const
  stringSet1 = toHashSet(["ay", "bee", "see", "dee"])
  • will throw the following error
/bookofnim.nim(64, 25) template/generic instantiation of `toHashSet` from here

nim-#version-2-0/lib/pure/collections/sets.nim(243, 26) template/generic 
instantiation of `initHashSet` from here

nim-#version-2-0/lib/pure/collections/sets.nim(116, 3) 
Error: Cannot prove that 'result' is initialized. 
This will become a compile time error in the future. [ProveInit]�
  • setting --experimental:strictNotNil in config.nim throws on nim source
assertions.nim(34)       raiseAssert
Error: unhandled exception: nilcheck.nim(1285, 3) `not typ.isNil`  [AssertionDefect]
  • setting --experimental:strictCaseObject caues the following to throw
import std/[critbits, strformat]

let sortedStringSet: CritBitTree[void] = ["zfirst", "asecond"].toCritBitTree

echo fmt"{sortedStringSet=}"

# im-#devel/lib/pure/collections/critbits.nim(249, 20)
# template/generic instantiation of `rawInsert` from here
# im-#devel/lib/pure/collections/critbits.nim(101, 14) 
# Error: field access outside of valid case branch: it.child�

-- setting --experimental:strictCaseObjects in config.nims throws on nim source

# in json
/nim-#devel/lib/pure/json.nim(250, 17) Error: field access outside of valid case branch

# in critbit
nim-#devel/lib/pure/collections/critbits.nim(101, 14) Error: field access outside of valid case branch: it.child

--- setting --experimental:views

/nim-#devel/lib/pure/asyncfutures.nim(63, 12) Error: 'result' must borrow from the first parameter

nim version

$ nim --v
Nim Compiler Version 1.9.3 [Linux: amd64]
Compiled at 2023-05-02
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: aec5a4c4744a81e19954daf330bafac948098835
active boot switches: -d:release
@noahehall noahehall changed the title limit errors to source code only limit errors to application source code only Apr 23, 2023
@noahehall
Copy link
Contributor Author

noahehall commented Apr 29, 2023

think this will (eventually?) be resolved in v2 per changelog

--styleCheck, --hintAsError and --warningAsError now only apply to the current package.

@noahehall noahehall changed the title limit errors to application source code only limit errors to application source code only and do not check imported packages/std library/etc May 1, 2023
@metagn
Copy link
Collaborator

metagn commented May 1, 2023

think this will (eventually?) be resolved in v2 per changelog

So the issue is fixed?

@noahehall
Copy link
Contributor Author

unfortunately no, issue still exists on #devel branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants