Skip to content

Forward goto after variable declaration causes crash #991

Description

@fosslinux

A goto to a different scope where a variable is declared before the label crashes when the variable is touched.

This is not totally unexpected behaviour to me, and is probably low-priority, but it might be nice to have an actual error, or even disallow this somehow.

Example:

method crash() {
    var b: Bool
    if (b) {
        goto l
    } else {
        var x: Bool := true
        label l
        assert x
    }
}

Output:

An exception was thrown while verifying method `crash`.
Verification aborted exceptionally: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.util.NoSuchElementException: java.util.NoSuchElementException: key not found: x
[TRUNCATED]
An exception occurred:
java.util.NoSuchElementException: java.util.NoSuchElementException: key not found: x
	at [TRUNCATED]
  [0] Verification aborted exceptionally (java.util.NoSuchElementException: java.util.NoSuchElementException: key not found: x, java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions