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

scanf can call procs with side-effects multiple times #6487

Closed
zacharycarter opened this issue Oct 8, 2017 · 0 comments
Closed

scanf can call procs with side-effects multiple times #6487

zacharycarter opened this issue Oct 8, 2017 · 0 comments

Comments

@zacharycarter
Copy link
Contributor

zacharycarter commented Oct 8, 2017

Two examples

  1. Will output "Someone called me!" twice
import strscans

proc test(): string = 
  echo "Someone called me!"
  result = ",123123"

var a: int
discard scanf(test(), ",$i", a)

and -

https://gist.github.com/anonymous/a8de94b5468e22788f5c966f09218726#file-playground-nim-L43-L48

and

https://gist.github.com/zacharycarter/54d176226f7be1c6cf96f41daf38803d

If you run this example using the configuration file linked, you'll notice that the call to scanf actually generates code which steps the config parser.

This should probably not happen.

@zacharycarter zacharycarter changed the title scanf in strscans module will step cfg parser from parsecfg module scanf can call procs with side-effects multiple times Oct 8, 2017
@Araq Araq closed this as completed in 5768eaa Oct 14, 2017
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

No branches or pull requests

1 participant