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

doc comment at end treats previous expression as discarded #9519

Closed
timotheecour opened this issue Oct 26, 2018 · 2 comments
Closed

doc comment at end treats previous expression as discarded #9519

timotheecour opened this issue Oct 26, 2018 · 2 comments
Labels
Documentation Generation Related to documentation generation (but not content). Parser

Comments

@timotheecour
Copy link
Member

not 100% sure whether this is a bug or by design but it is surprising:

this gives:
Error: expression 'fun0()' is of type 'string' and has to be discarded
changing ## foo to # foo removes the error

when defined(true):
  template foo(fun): untyped=
    fun()
    ## foo

  proc fun0(): auto = "asdf"
  echo foo(fun0)
@Araq
Copy link
Member

Araq commented Oct 26, 2018

It's by design, the rationale here is

a) it's hard to care for these nkDocComment nodes everywhere in the sematic checking.
b) conceptually it's like Python's """foo""" documentation string/comment and so is allowed to influence the type/discard checking.

@krux02 krux02 changed the title doc comment after last expression results in error doc comment at end treats previous expression as discarded Oct 26, 2018
@krux02
Copy link
Contributor

krux02 commented Oct 26, 2018

Is the question answered? Can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Generation Related to documentation generation (but not content). Parser
Projects
None yet
Development

No branches or pull requests

3 participants