verachell / YeetWords

a domain-specific language for text substitution
GNU General Public License v3.0
13 stars 0 forks source link

Ruby interpreter error on initital tutorial #3

Closed dariusk closed 3 years ago

dariusk commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Sounds good, thank you! I'm having a lot of fun with the tool so far, btw. The documentation is great, too.

On Mon, Nov 1, 2021, 3:42 PM Vera Chellgren @.***> wrote:

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

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/verachell/YeetWords/issues/3#issuecomment-956785349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACBBVSBVU5KYDRUHS4B5H3UJ4JT5ANCNFSM5HESPKSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

verachell commented 3 years ago

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 https://github.com/verachell/YeetWords/issues/4 next (LOOP command).