Skip to content

Commit 682d405

Browse files
committed
fix a crash in data def compilation
1 parent bef7e15 commit 682d405

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/compile/data.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ impl Compiler {
277277

278278
let mut variant_index = 0;
279279
if data.variant {
280-
let module_scope = self.higher_scopes.last_mut().unwrap_or(&mut self.scope);
281-
variant_index = module_scope.data_variants.len();
282-
let name = data.name.as_ref().unwrap().value.clone();
283-
module_scope.data_variants.insert(name);
280+
if let Some(name) = data.name.as_ref() {
281+
let module_scope = self.higher_scopes.last_mut().unwrap_or(&mut self.scope);
282+
variant_index = module_scope.data_variants.len();
283+
module_scope.data_variants.insert(name.value.clone());
284+
}
284285
}
285286

286287
// Make getters

tests_special/error.ua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,6 @@ F ← |0.1000 ⍢(F F F|1)
182182

183183
°⊸(⌝⤸0) ⇡3 °△3_3
184184

185-
⊥1 5
185+
⊥1 5
186+
187+
|

0 commit comments

Comments
 (0)