Skip to content

Conversation

@timotheecour
Copy link
Member

@timotheecour timotheecour commented Apr 16, 2021

  • introduces --filenames:abs|canonical|legacyRelProj for filenames in compiler msgs (replaces --listfullpaths:on|off which is kept for backward compatibility)
    --filenames:abs is same as the old --listfullpaths:on
    --filenames:legacyRelProj is the same as the old --listfullpaths:off
    --filenames:canonical reuses the code from fix #16973 ; nim doc now shows correct, canonical import name in title #16999
    --listfullpaths:off is now mapped to --filenames:canonical (but i could change it to --filenames:legacyRelProj if needed)

  • supersedes and closes [superseded] --listFullPaths:off now shows paths relative to cwd #13058, it'll be very easy to add --filenames:relative after this PR if needed

  • --filenames:canonical is more context-independent, stable (independent of where nimble packages are installed) and less surprising than --filenames:legacyRelProj which was sometimes showing relative paths wrt main project name, sometimes show ../ in path, and sometimes show absolute paths

example 1

when true:
  import compiler/options
  var a: ConfigRef2

--filenames:canonical

tests/nim/all/t12177.nim(21, 10) Error: undeclared identifier: 'ConfigRef2'
candidates (edit distance, scope distance); see '--spellSuggest':
 (1, 2): 'ConfigRef' [type declared in compiler/options.nim(268, 3)]
    var a: ConfigRef2

--filenames:legacyRelProj

t12177.nim(21, 10) Error: undeclared identifier: 'ConfigRef2'
candidates (edit distance, scope distance); see '--spellSuggest':
 (1, 2): 'ConfigRef' [type declared in /Users/timothee/git_clone/nim/Nim_prs/compiler/options.nim(268, 3)]
    var a: ConfigRef2

=> as you can see the relative vs absolute paths with --filenames:legacyRelProj (old --listfullpaths:off)are non-intuitive

example 2

with a nimble package

when true:
  import pkg/regex
  var a = re(12)

nim r --filenames:canonical /pathto/tests/nim/all/t12177.nim

tests/nim/all/t12177.nim(17, 13) Error: type mismatch: got <int literal(12)>
but expected one of:
func re(s: static string): static[Regex] [func declared in regex.nim(289, 8)]
  first type mismatch at position: 1
  required type for s: static[string] [static declared in regex.nim(290, 5)]
  but expression '12' is of type: int literal(12) [int declared in system/basic_types.nim(2, 3)]
...

note

future work

@timotheecour timotheecour added the TODO: followup needed remove tag once fixed or tracked elsewhere label Apr 17, 2021
@timotheecour timotheecour force-pushed the pr_filename_magicSauce_improve branch from 541c699 to 44b1018 Compare April 19, 2021 22:23
@timotheecour timotheecour changed the title use canonical module name in error messages (replaces foMagicSauce logic) --filenames:abs|canonical|magic for filenames in compiler msgs (replaces --listfullpaths:on|off) Apr 20, 2021
@timotheecour timotheecour force-pushed the pr_filename_magicSauce_improve branch from 28f5933 to 1a1ea72 Compare April 20, 2021 02:37
@timotheecour timotheecour changed the title --filenames:abs|canonical|magic for filenames in compiler msgs (replaces --listfullpaths:on|off) --filenames:abs|canonical|legacyRelProj for filenames in compiler msgs (replaces --listfullpaths:on|off) Apr 20, 2021
@timotheecour timotheecour marked this pull request as ready for review April 20, 2021 06:32
@timotheecour timotheecour force-pushed the pr_filename_magicSauce_improve branch from 1a1ea72 to 3c5490b Compare April 20, 2021 20:32
@timotheecour timotheecour reopened this Apr 21, 2021
@Araq Araq merged commit da1c1a7 into nim-lang:devel Apr 21, 2021
@timotheecour timotheecour deleted the pr_filename_magicSauce_improve branch April 21, 2021 18:19
timotheecour added a commit to timotheecour/Nim that referenced this pull request Apr 27, 2021
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
…sgs (replaces `--listfullpaths:on|off`) (nim-lang#17746)

* use canonicalImport for filename_magicSauce
* --filenames:abs|canonical|magic
* rename: magic => legacyRelProj
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TODO: followup needed remove tag once fixed or tracked elsewhere

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants