Skip to content

Conversation

@timotheecour
Copy link
Member

@timotheecour timotheecour commented Jul 17, 2021

this PR adds a way to indicate an API had a change in semantics, and, when a custom defined flag is used, it will issue a new migrated warning showing both the call site and the callee symbol location, along with custom msg. eg:

proc getHomeDir*(): string {....
  migrated(nimMigratedGetHomeDir, "`getHomeDir` now does not end in DirSep, see `normalizePathEnd`").} =
import os
proc main()=
  echo getHomeDir()
main()
echo getHomeDir()

nim c main:

tests/nim/all/t12601.nim(158, 10) Warning: `getHomeDir` now does not end in DirSep, see `normalizePathEnd`; getHomeDir was migrated [proc declared in std/os(889, 6)] [Migrated]
tests/nim/all/t12601.nim(160, 8) Warning: `getHomeDir` now does not end in DirSep, see `normalizePathEnd`; getHomeDir was migrated [proc declared in std/os(889, 6)] [Migrated]

if you pass -u:nimMigratedGetHomeDir on cmdline, the warning disappears.
ditto in your user config.nims with switch("undef", "nimMigratedGetHomeDir")

you can also use --warningAsError:migrated to transform those warnings into errors, as usual

This PR (.migrated) and #18496 (--moduleoverride) address main pain points when upgrading to a new compiler version (or more generally, to a new version of a library, it's not tied to compiler changes but more generally to API changes).

future work

  • allow --warning:foo:foreign:on|off to control whether to enable warnings for foreign packages; note that notes are currently turned off for foreign package notes (sane default) but in some cases it's useful to still issue those (not just for migrated warning but more generally); ditto with hints.

@timotheecour timotheecour changed the title add {.migrated(nimMigratedFoo, "foo changed its semantics: ...").} add {.migrated:... .} pragma to indicate APIs whose semantics have changed Jul 17, 2021
@timotheecour timotheecour changed the title add {.migrated:... .} pragma to indicate APIs whose semantics have changed add {.migrated(ident, msg):... .} to issue callsite migration warnings for changed APIs Jul 17, 2021
@timotheecour timotheecour added the Ready For Review (please take another look): ready for next review round label Jul 17, 2021
@stale
Copy link

stale bot commented Jul 30, 2022

This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Jul 30, 2022
@stale stale bot closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready For Review (please take another look): ready for next review round stale Staled PR/issues; remove the label after fixing them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant