Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task]: Fix fixed length array size overflowing #42684

Closed
lochana-chathura opened this issue May 3, 2024 · 3 comments
Closed

[Task]: Fix fixed length array size overflowing #42684

lochana-chathura opened this issue May 3, 2024 · 3 comments
Assignees
Labels
Area/SemtypePort Issues related to porting of semantic subtyping Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task

Comments

@lochana-chathura
Copy link
Member

lochana-chathura commented May 3, 2024

Description

$subject. The following tests fail at the moment. It is included in the fixed-length-array-large-t.bal added by PR #42663.

public const int MAX_VALUE = 9223372036854775807;

public const int MAX_VALUE_M_1 = MAX_VALUE - 1;

// @type LargeArray < IntArray
type LargeArray int[MAX_VALUE];

// @type LargeArray <> LargeArray2
type LargeArray2 int[MAX_VALUE_M_1];
@lochana-chathura lochana-chathura added Type/Task Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/SemtypePort Issues related to porting of semantic subtyping labels May 3, 2024
@heshanpadmasiri heshanpadmasiri self-assigned this May 6, 2024
@heshanpadmasiri
Copy link
Member

heshanpadmasiri commented May 6, 2024

We already support array lengths that are constants

This is caused by an integer overflow here. But in general I think this indicate fixed length must be a long not an int to have the same behavior as nBallerina. Will send a fix

@heshanpadmasiri heshanpadmasiri changed the title [Task]: Support in semtype resolver when the array length is a constant [Task]: Fix fixed length array size overflowing May 6, 2024
@heshanpadmasiri
Copy link
Member

After an offline chat we decided not support this and instead give a proper error for such overflow. This is because our lists are internally backed by java arrays and their indices have an upper limit enforced by int not long. Note this is consistent with the existing behavior of jBallerina

@lochana-chathura
Copy link
Member Author

Closing with #42701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemtypePort Issues related to porting of semantic subtyping Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task
Projects
None yet
Development

No branches or pull requests

2 participants