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 #8100 #8101

Merged
merged 1 commit into from
Jun 29, 2018
Merged

Fixes #8100 #8101

merged 1 commit into from
Jun 29, 2018

Conversation

GULPF
Copy link
Member

@GULPF GULPF commented Jun 24, 2018

I looked for a less hacky way to check if a proc returns void, but couldn't find any. Related: #7397

@metagn
Copy link
Collaborator

metagn commented Jun 24, 2018

You could technically do not compiles(type(format(arg, res))) if that feature doesn't get implemented. Also you can do compiles do: instead of compiles((block:

@@ -258,7 +258,9 @@ template callFormat(res, arg) {.dirty.} =
# workaround in order to circumvent 'strutils.format' which matches
# too but doesn't adhere to our protocol.
res.add arg
elif compiles(format(arg, res)):
elif compiles(format(arg, res)) and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the following would be better?

elif compiles((var res = ""; format(arg, res)))

Strange that the current code doesn't catch the "return value needs to be discarded" error. Maybe the above version will?

@GULPF
Copy link
Member Author

GULPF commented Jun 26, 2018

Strange that the current code doesn't catch the "return value needs to be discarded" error. Maybe the above version will?

It's because compiles expects an expression and not a statement, and expressions doesn't need to be discarded.

I switched to the do version because it looks slightly better IMO.

@Araq
Copy link
Member

Araq commented Jun 27, 2018

Travis hickup, closing and re-opening.

@Araq Araq closed this Jun 27, 2018
@Araq Araq reopened this Jun 27, 2018
@Araq Araq merged commit 7674df0 into nim-lang:devel Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants