Skip to content

ND_CONTINUEにて、continueのtargetブロックがcontinuesでなくbreakになっている #29

Description

@programmerkgit

parse.c 846行目, 以下のようにbreaksではなくcontinuesに直すのが正しいように思います

case TK_CONTINUE: {
    if (continues->len == 0)
      bad_token(t, "stray continue");
    Node *node = new_node(ND_CONTINUE, t);
    --- 現状
    node->target = vec_last(breaks); 
    ---
    --- 正
    node->target = vec_last(continues);
    ---
    return node;
  }

以下のような、forの内側のswitchのcontinueなどc langで可能な構文がparseに失敗します。

int main() {
  int a = 1;
  for (;;) {
    switch (a) {
    case 1:
      continue;
      break;
    }
  }
  return 1;
}

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