Skip to content

regression: runnableExamples in template should not affect caller #16993

Closed
@timotheecour

Description

@timotheecour

reduced from CI failure in #16988

Example

# t11840b.nim:
template doAssert2*(cond: untyped) =
  ## foo
  runnableExamples:
    echo "D20210209T192323"
  discard

# main.nim:
import t11840b
doAssert2 true
doAssert2 true
doAssert2 true

nim doc main.nm

Current Output

D20210209T192323
D20210209T192323
D20210209T192323

Expected Output

(nothing)

Additional Information

worked in 0.19.0
fails since 0.19.6 including devel 1.5.1 0d34345

as an example, this prevents adding runnableExamples in doAssert (refs #16988) but obviously this affects other code, eg when adding runnableExamples to a template.

Note that transforming a proc (that would contain a runnableExamples) to a template shouldn't affect semantics wrt runnableExamples.
Also note that current behavior is bad because it makes it impossible to add runnableExamples to templates without it affecting semantics as demoed here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions