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

Ruby interpreter error on initital tutorial #3

Closed
dariusk opened this issue Nov 1, 2021 · 4 comments · Fixed by #5
Closed

Ruby interpreter error on initital tutorial #3

dariusk opened this issue Nov 1, 2021 · 4 comments · Fixed by #5
Labels
bug Something isn't working

Comments

@dariusk
Copy link

dariusk commented Nov 1, 2021

Hello! I'm very excited to try YeetWords out for NaNoGenMo. I did immediately run into an issue doing the quick start tutorial. Here's my entire project:

sentence/mysentences.txt

I picked up the _NOUN_

word/noun.txt

hammer
saw
screwdriver
panda

novel.txt

WRITE mysentences wfolder 50000W

When I run ruby yeetwords.rb novel.txt, this is the output:

Y| WELCOME :)
Y| Running your program...
Y| Reading file mysentences.txt
Y| Reading file noun.txt
<internal:kernel>:48:in `initialize_clone': stack level too deep (SystemStackError)
	from <internal:kernel>:48:in `clone'
	from yeetwords.rb:133:in `select_random'
	from yeetwords.rb:2090:in `one_sentence_suball'
	from yeetwords.rb:1463:in `standard_write'
	from yeetwords.rb:1491:in `standard_write'
	from yeetwords.rb:1491:in `standard_write'
	from yeetwords.rb:1491:in `standard_write'
	from yeetwords.rb:1491:in `standard_write'
	 ... 4509 levels...
	from yeetwords.rb:2272:in `block in loop_iterator'
	from yeetwords.rb:2268:in `each'
	from yeetwords.rb:2268:in `loop_iterator'
	from yeetwords.rb:2374:in `<main>'

Clearly it's too many loops, and when I drop it down to 20000W it works fine. I'm sure I could manually update my maximum stack size somewhere in my Ruby or system settings to fix the problem. But anyway, this is a Ruby error and should probably output something more human-friendly so I'm reporting it here!

@verachell
Copy link
Owner

Oh gosh, thank you for alerting me to this error! I am looking into it. I have replicated your error on my system and can confirm we are looking at the same error.

I am trying to figure out with my code where the problem is.

@verachell
Copy link
Owner

Some good news and some bad news. The good news: I am on track for making a bug fix for this specific issue. Basically, I tried rewriting my function standard_write iteratively instead of recursively so as hopefully not to run out of stack space, and that change solved your specific problem. It's not up yet as a pull request because I need to tighten up the rewritten function a bit more, make sure other calls from elsewhere to that function go smoothly, and do more local testing first. But on a preliminary local test with your exact data as above, it works and produces 50000 words output. I'm hoping to have that specific item in as a pull request in the dev branch around 24h from now if there are no hiccups cropping up with that change and if I can complete the testing in that timeframe.

The bad news: If I change your novel.txt code to instead achieve the number of words via a LOOP command as shown below, then again we wind up with a stack level too deep error on ruby interpreter. Most likely, I'll have to also rewrite my loop_iterator function iteratively :( which is recursive despite its name! I'll raise this one as a separate issue.

LOOP 50000W
WRITE mysentences wfolder
LOOPEND

Interestingly, not all instances of LOOP 50000W have problems in YeetWords - I have one in another repository that is working fine, see https://github.com/verachell/Limericks-NaNoGenMo-2021

One bug fix at a time though - I'll go ahead first with the bug fix specific to the issue you raised.

@dariusk
Copy link
Author

dariusk commented Nov 1, 2021 via email

@verachell verachell added bug Something isn't working STATUS: in progress actively being worked on STATUS: testing a candidate fix is being tested locally (no pull request yet) STATUS: pull request made and removed STATUS: testing a candidate fix is being tested locally (no pull request yet) labels Nov 2, 2021
@verachell verachell removed the STATUS: in progress actively being worked on label Nov 2, 2021
@verachell
Copy link
Owner

Thank you so much for bringing this problem with the WRITE command to my attention! I have now fixed this problem, tested the solution, and the changes have been merged into the main branch. The 1.1.1 release reflects this change. Let me know if you have any questions.

I'm going to tackle the similar issue #4 next (LOOP command).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants