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

fixes #8301; disallow typedesc being assigned to result #20664

Closed
wants to merge 5 commits into from
Closed

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Oct 26, 2022

fixes #8301

tyVoid matches tyAnthing; the same thing goes for fitNode;

# bug #8301
proc foo_1():auto=
  void

when true:
  # Error: internal error: expr: var not init result_115006
  foo_p1()

@ringabout ringabout changed the title fixes #8301; fixes void assigned to result fixes #8301; disallow void being assigned to result Oct 26, 2022
@metagn
Copy link
Collaborator

metagn commented Oct 26, 2022

Why specialize for void? There is no mechanism that deals with this for any typedesc.

proc foo: auto = int

foo() # expr: var not init result_436207618

@ringabout
Copy link
Member Author

ringabout commented Oct 26, 2022

Thank you! I'm gonna to do it for typedesc.

@ringabout
Copy link
Member Author

ringabout commented Oct 26, 2022

It seems there are more discussion about it:

#16846
#11959
#16601
#16600

@ringabout ringabout marked this pull request as draft October 26, 2022 17:26
@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Oct 26, 2022

Whats useful for using typedesc as return type?, it is Ok for argument types, but for return types?.
Maybe just disallow typedesc as return type, or at least a warning. 🤔

@ringabout
Copy link
Member Author

ringabout commented Oct 26, 2022

The Nim manual only mentions typedesc used as the return type of macros. I will work on disallowing typedesc being assigned to result (with typedesc/tyAnything). It should be an improvement compared to the compiler crash. We can remove the restriction when the time is ripe.

@ringabout ringabout changed the title fixes #8301; disallow void being assigned to result fixes #8301; disallow typedesc being assigned to result Oct 27, 2022
@ringabout ringabout marked this pull request as ready for review October 27, 2022 03:44
@ringabout
Copy link
Member Author

It would be nice to have compile time procs return typedesc. But until then we should provide better error messages for what were compiler crashes.

@Araq
Copy link
Member

Araq commented Oct 27, 2022

Nothing is special about assignment here either:

proc foo(x: auto) = discard

foo(void)

This is already not allowed but then why is it for assignments?

@Varriount Varriount requested a review from Araq October 27, 2022 17:27
@Varriount Varriount added the Requires Araq To Merge PR should only be merged by Araq label Oct 27, 2022
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for 1 year with no activity. Contribute more commits on the pull request and rebase it on the latest devel, or it will be closed in 30 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Staled PR/issues; remove the label after fixing them label Oct 28, 2023
Copy link
Contributor

This pull request has been marked as stale and closed due to inactivity after 395 days.

@github-actions github-actions bot closed this Nov 27, 2023
@narimiran narimiran deleted the pr_foo branch January 13, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requires Araq To Merge PR should only be merged by Araq stale Staled PR/issues; remove the label after fixing them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[minor][error message] Error: internal error: expr(skType); unknown symbol
5 participants