Skip to content

Commit

Permalink
Add __crash_compiler to aid debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Dec 2, 2024
1 parent 001129d commit a3ce9cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/instantiation/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> {
match linker_cst.link_info.name.as_str() {
"true" => TypedValue{value: Value::Bool(true), typ: ConcreteType::Named(get_builtin_type("bool"))},
"false" => TypedValue{value: Value::Bool(false), typ: ConcreteType::Named(get_builtin_type("bool"))},
"__crash_compiler" => {
cst_ref.get_total_span().debug();
panic!("__crash_compiler Intentional ICE. This is for debugging the compiler and LSP.")
}
other => unreachable!("{other} is not a known builtin constant")
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions stl/core.sus
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ __builtin__ struct bool {}
// An integer of variable size. Right now it's not implemented yet, so this is just a 32-bit int.
__builtin__ struct int {}

// For intentionally triggering an ICE for debugging. It is a constant that crashes the compiler when it is evaluated
__builtin__ const bool __crash_compiler {}

// True, as in '1'
__builtin__ const bool true {}
// False, as in '0'
Expand Down

0 comments on commit a3ce9cf

Please sign in to comment.