Skip to content

Web IDE crashes when running program #37

@Heathcorp

Description

@Heathcorp

Possible code generation bug shown by this code, when run, the program gets stuck in the inner drain loop.

// example:
// 3 3388833555666706 666777 330933 06444 4 448
// ouputs: DEVELOP MORE WE MIGHT
cell FIFTY = 50;

cell run_length = 0;
cell curr;
cell prev; input prev;
drain FIFTY {
  while prev {
    input curr;
    run_length += 1;
    cell[3] _prevs;
    cell __prev;
    drain prev into *_prevs __prev;
    _prevs[0] -= curr;
    drain _prevs[0] {
      _prevs[0] = 0;
      // different character to previous
      // ignore if space
      _prevs[1] -= ' ';
      drain _prevs[1] {
        _prevs[1] = 0;
        // output space if digit 0
        __prev -= '0';
        if not __prev {
          output ' ';
        } else {
          // calculate correct character to output
          cell ch;
          __prev -= 2;
          cell shift_flag = 6;
          drain __prev {
// gets stuck in this loop
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
            shift_flag -= 1;
            ch += 4;
            if shift_flag {
              ch -= 1;
            }
          }
          ch += 'A' - 1;
          drain run_length into ch;
          output ch;
        }
      }
      run_length = 0;
    }

    drain curr into prev;
  output '\n';
  output '\n';
  output '\n';
  output '\n';
  output '\n';
  }
  input prev;
  output '\n';
}

BF program generated:

+++++[<++++++++++>-]>>,<<<
[
  >>>
  [
    <,<+>>
    [->+>+>+>+<<<<]<[->>->>>>+<<<<<<]
    >>>>>>[<<<<<<+>>>>>>-]
    <<<<[
      [-]
      >>>>++++[<<<-------->>>-]
      <<<[
        [-]
        >>>++++++[<-------->-]
        >+<<[->+>>+<<<]
        >>>[<<<+>>>-]
        <<[[-]>[-]
          >>++++++<<<<--[
            >>>>>.........<-<++++
            >[->+>+<<]>>[<<+>>-]
            <[[-]<<->>]
            <<<<<-
          ]
          >>>>>++++++++[<<++++++++>>-]<<<<<<<<<<<[->>>>>>>>>+<<<<<<<<<]
          >>>>>>>>>.
          >[-]<[-]<<
        ]
        >[[-]>++++[<<++++++++>>-]
          <<.[-]>
        ]
        <<<<-
      ]
      <<<<[-]>>>-
    ]
    <<[->+<]
    >>>>>>++++++++++.[-]++++++++++.[-]++++++++++.[-]++++++++++.[-]++++++++++.[-]
    <<<[-]>[-]>[-]<<<<
  ]
  ,>++++++++++.
  [-]<<<<-
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtsweb

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions