-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
P: lowaudit-reportRelated to the audit reportRelated to the audit reportbugSomething isn't workingSomething isn't workingteam:compilerCompiler TeamCompiler Team
Description
CS-FSSA-021
Empty arrays are assigned the never type. Never type is treated as a subtype of all types. This means
that a never array should be assignable to an empty array of any other type. Moroever, if we assign an
empty array to a type-ascribed variable, the type of this variable should be its ascription. This is not true
in the following example.
script;
impl [u32;0] {
fn foo(self){
log("32");
}
}
impl [!;0] {
fn foo(self){
log("never");
}
}
fn main() {
let x:[u32;0] = [];
x.foo(); // logs "never"
}
The never type in arrays is more problematic considering the following case which also compiles:
let x:[u32;0] = [];
let y: [!;0] = x;
As one would expect x to preserve its ascription assigning x to y should fail since the never type is a
subtype of the [u32;0].
Metadata
Metadata
Assignees
Labels
P: lowaudit-reportRelated to the audit reportRelated to the audit reportbugSomething isn't workingSomething isn't workingteam:compilerCompiler TeamCompiler Team