Skip to content

Commit

Permalink
deprecate the .codegenDecl pragma (#1358)
Browse files Browse the repository at this point in the history
## Summary

The `.codegenDecl` pragma is going to be removed eventually. For a
transition period, a deprecation warning is now reported when using it.
  • Loading branch information
zerbina authored Jun 26, 2024
1 parent 9e4bdb0 commit e0ad8b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/ast/report_enums.nim
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ type
rsemLockLevelMismatch = "LockLevel"
rsemTypelessParam = "TypelessParam"
rsemOwnedTypeDeprecated
rsemCodegenDeclDeprecated = "Deprecated"

rsemWarnUnlistedRaises = "Effect" ## `sempass2.checkRaisesSpec` had
## `emitWarnings: bool` parameter which was supposedly used to control
Expand Down
4 changes: 4 additions & 0 deletions compiler/front/cli_reporter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ proc reportBody*(conf: ConfigRef, r: SemReport): string =
of rsemOwnedTypeDeprecated:
result = "the `owned` type-operator is deprecated and treated as a no-op"

of rsemCodegenDeclDeprecated:
result = "the `.codegenDecl` pragma is deprecated; support for it " &
"will be removed in the future"

of rsemLinterReport:
result.addf("'$1' should be: '$2'", r.linterFail.got, r.linterFail.wanted)

Expand Down
2 changes: 2 additions & 0 deletions compiler/sem/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ proc processCodegenDecl(c: PContext, n: PNode, sym: PSym): PNode =
## the string literal from `n`
result = getStrLitNode(c, n)
sym.constraint = result
# issue a deprecation warning:
c.config.localReport(n.info, reportSem(rsemCodegenDeclDeprecated))

proc processMagic(c: PContext, n: PNode, s: PSym): PNode =
## produces an error if `n` is not a pragmacall kinds, otherwise `n` is
Expand Down

0 comments on commit e0ad8b1

Please sign in to comment.