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

Compailers panics when const evaluating const initialized by a const function call #6960

Open
ironcev opened this issue Feb 25, 2025 · 0 comments
Labels
bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team

Comments

@ironcev
Copy link
Member

ironcev commented Feb 25, 2025

Compiling the following code:

library;

struct S1 {}

fn eval_s_c(val: u8) -> u8 {
    val
}

impl S1 {
    const S_C: u8 = eval_s_c(111);
}

will result in:

thread 'main' panicked at sway-core/src/semantic_analysis/type_check_analysis.rs:64:44:
called `Option::unwrap()` on a `None` value

The code at type_check_analysis.rs:64:44 is:

pub fn add_edge_from_current(&mut self, to: TyNodeDepGraphNodeId, edge: TyNodeDepGraphEdge) {
    let from = *self.node_stack.last().unwrap();  // <<<<----
    if !self.dep_graph.contains_edge(from, to) {
        self.dep_graph.add_edge(from, to, edge);
    }
}

Example on Sway Playground fails already on Forc v0.66.5.

@ironcev ironcev added bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team
Projects
None yet
Development

No branches or pull requests

1 participant