Skip to content

Sunset freezes on assigning function results to array elements #18

@Dozzler

Description

@Dozzler

This occurs when in said function two or more arrays are declared in a comma-separated list:

program calculate{
	function foo() : Integer {
		a,b : Z(3)[];  // comma-separated list of two arrays.
		
		return 1;
	}

	a : Integer[];
	a := new Integer[2];
	a[1] := foo(); // This freezes
}

The exception provided is as follows:

Exception in thread "Thread-142" java.lang.ClassCastException: class ffapl.java.classes.Array cannot be cast to class ffapl.java.classes.BInteger (ffapl.java.classes.Array and ffapl.java.classes.BInteger are in unnamed module of loader 'app')
	at ffapl.java.FFaplVm.storeArrayElement(FFaplVm.java:242)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:334)
	at ffapl.ast.nodes.ASTAssignment.accept(ASTAssignment.java:72)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1973)
	at ffapl.ast.nodes.FFaplNodeChoice.accept(FFaplNodeChoice.java:102)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1865)
	at ffapl.ast.nodes.ASTStatement.accept(ASTStatement.java:62)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:2022)
	at ffapl.ast.nodes.FFaplNodeSequence.accept(FFaplNodeSequence.java:54)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1973)
	at ffapl.ast.nodes.FFaplNodeChoice.accept(FFaplNodeChoice.java:102)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1997)
	at ffapl.ast.nodes.FFaplNodeListOpt.accept(FFaplNodeListOpt.java:53)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1877)
	at ffapl.ast.nodes.ASTStatementList.accept(ASTStatementList.java:62)
	at ffapl.visitor.FFaplJavaInterpreterVisitor.visit(FFaplJavaInterpreterVisitor.java:1630)
	at ffapl.FFaplInterpreter.run(FFaplInterpreter.java:80)

In the following cases, this problem does NOT occur:

1 . Assigning function result to non-array variables

program calculate{
	function foo() : Integer {
		a,b : Z(3)[];  // comma-separated list of two arrays.
		
		return 1;
	}

	a : Integer;
	a := foo(); // No freeze
}
  1. Arrays declared in separate lines
program calculate{
	function foo() : Integer {
		a : Z(3)[]; 
                b : Z(3)[];
		
		return 1;
	}

	a : Integer[];
	a := new Integer[2];
	a[1] := foo(); // No freeze
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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