-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Consider the following example:
type TestType {
Case1
Case2(field1: String, field2: Number)
}
component Main {
fun render : Html {
let t = TestType.Case2("case2 text", 1)
let text = case t {
Case1 => "case1"
Case2(field0, field1, field2) => field1
}
<div>{text}</div>
}
}
Sandbox: https://mint-lang.com/sandbox/RsOceFy-_uKexg
The failure here is line Case2(field0, field1, field2) => field1
referring to field0
which doesn't exist in the TestType.Case2. As I've found out the destructured field name doesn't matter. The error is only about amount of destructured fields.
Index out of bounds (IndexError)
'raise<IndexError>:NoReturn'
'Mint::TypeChecker#destructure<Mint::Ast::TypeDestructuring, (Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)>:Array(Tuple(String, Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable, Mint::Ast::Node+))'
'Mint::TypeChecker#resolve<Mint::Ast::CaseBranch, (Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check<Mint::Ast::Case>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#resolve<Mint::Ast::Node+>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check<Mint::Ast::Statement>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#resolve<Mint::Ast::Statement>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check<Mint::Ast::Block>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#resolve<Mint::Ast::Block>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check_function<Mint::Ast::Function>:Mint::TypeChecker::Type'
'Mint::TypeChecker#resolve<Mint::Ast::Function>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check<Mint::Ast::Component>:Mint::TypeChecker::Type'
'Mint::TypeChecker#resolve<Mint::Ast::Component>:(Mint::TypeChecker::Record | Mint::TypeChecker::Type | Mint::TypeChecker::Variable)'
'Mint::TypeChecker#check:Mint::TypeChecker::Artifacts'
'Mint::Workspace#update<Array(String), Symbol>:(Set(Tuple(String, Time)) | Nil)'
'Mint::Watcher#scan<Symbol>:Set(Tuple(String, Time))'
'Mint::Workspace#reset:(Set(Tuple(String, Time)) | Nil)'
'Mint::Workspace::new:path:dot_env:check:include_tests:format:listener<String, String, Mint::Check, Bool, Bool, Proc((Mint::Error | Mint::TypeChecker), Nil)>:Mint::Workspace'
'Mint::Cli::Start#parse_and_run:Nil'
'Mint::Cli#parse_and_run:Nil'
'__crystal_main'
'Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32'
'main'
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working