-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
P: criticalShould be looked at before anything elseShould be looked at before anything elsebugSomething isn't workingSomething isn't workingcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgenEverything to do with type checking, control flow analysis, and everything between parsing and IRgencompiler: irIRgen and sway-ir including optimization passesIRgen and sway-ir including optimization passesteam:compilerCompiler TeamCompiler Team
Description
The following compiles but X is not actually constant evaluated. If we move the definition of X to the global scope, then we get an error saying Could not evaluate initializer to a const declaration. as expected.
script;
fn bla(x: u64) -> u64 {
x + 1
}
fn main() -> u64 {
const X = bla(0);
X
}It is possible that this behavior is desirable. If so, we should properly document it. If not, then this is a bug.
Metadata
Metadata
Assignees
Labels
P: criticalShould be looked at before anything elseShould be looked at before anything elsebugSomething isn't workingSomething isn't workingcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgenEverything to do with type checking, control flow analysis, and everything between parsing and IRgencompiler: irIRgen and sway-ir including optimization passesIRgen and sway-ir including optimization passesteam:compilerCompiler TeamCompiler Team
Type
Projects
Status
Done