Skip to content

Report minimal repro of let cmd = cmd upstream #6

Description

@lukateras

https://en.wikipedia.org/wiki/Minimal_working_example

Relevant code:

func parse(commands: seq[Command]): seq[Instruction] =
  var loopMatches: seq[Instruction]
  var n = 1

  for i, cmd in commands:
    let cmd = cmd # ?!
    case cmd:
      of LoopStart, LoopEnd:
        let instruction = Instruction(command: cmd, i: result.len)
        result.add(instruction)
        if cmd == LoopStart:
          loopMatches.add(instruction)
        else:
          swap(instruction.i, loopMatches.pop.i)
      else:
        if i == commands.len - 1 or cmd != commands[i + 1]:
          result.add(Instruction(command: cmd, n: n))
          n = 1
        else:
          n += 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions