lookharm / go-brainfuck

Brainfuck interpreter written in Go
MIT License
0 stars 1 forks source link

Panic during execution of Brainfuck code #1

Closed lookharm closed 1 year ago

lookharm commented 1 year ago

Description: While executing the provided Brainfuck code snippet, a panic occurs instead of generating the expected output. The panic indicates an unexpected error or invalid state during the execution.

Code:

code = `+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.`
output := Run(code, nil)
if string(output) != "Hello World!\n" {
    t.FailNow()
}

Expected Output: "Hello World!\n"

Actual Behavior: Panic occurs during code execution

To Reproduce:

  1. Use the provided code snippet in a test case.
  2. Execute the test case.
  3. Observe the panic message or error stack trace.

Environment:

alipashamontaseri commented 1 year ago

The BF code shouldn't in fact execute successfully (you can try via the online interpreter here) as it is trying to move the pointer to negative values.

lookharm commented 1 year ago

The issue has been closed based on the reason provided by Kalam132.