Skip to content

Huge Logical Error #1

@Asphocarp

Description

@Asphocarp

In compiler.go

			// if.body
			func() {
				defer p.restoreScope(p.scope)
				p.enterScope()

				fmt.Fprintf(w, "\n%s:\n", ifBody)
				if stmt.Else != nil {
					p.compileStmt(w, stmt.Body)
					fmt.Fprintf(w, "\tbr label %%%s\n", ifElse) // here
				} else {
					p.compileStmt(w, stmt.Body)
					fmt.Fprintf(w, "\tbr label %%%s\n", ifEnd)
				}
			}()

the ifElse should be ifEnd !

By the way, I am also curious about why labels ifInit and ifCond are needed, since they are branched to immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions