[fine] Report errors with environments, fix match bug
I'm worried that this will turn into something I always have to do instead of something I just do sometimes: always provide the provenance of some error type or another. Link error types to diagnostics, etc.
This commit is contained in:
parent
2ba34701ac
commit
8779aade24
3 changed files with 41 additions and 30 deletions
|
|
@ -556,7 +556,7 @@ fn compile_binary_expression(c: &mut Compiler, t: TreeRef, tr: &Tree) -> CR {
|
|||
let ltree = &c.syntax[lvalue];
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
let mut environment = Environment::error();
|
||||
let mut environment = Environment::error("??");
|
||||
|
||||
let declaration = match ltree.kind {
|
||||
// TODO: Assign to list access
|
||||
|
|
@ -752,10 +752,11 @@ fn compile_pattern(c: &mut Compiler, t: TreeRef) -> CR {
|
|||
// If you have a binding, dup and store now, it is in scope.
|
||||
if let Some(binding) = tree.child_tree_of_kind(&c.syntax, TreeKind::VariableBinding) {
|
||||
if let Some(variable) = binding.nth_token(0) {
|
||||
let id = variable.as_str(&c.source);
|
||||
let environment = c.semantics.environment_of(t);
|
||||
let declaration = environment
|
||||
.bind(variable.as_str(&c.source))
|
||||
.ok_or("not bound")?;
|
||||
let Some(declaration) = environment.bind(id) else {
|
||||
ice!(c, t, "cannot bind pattern variable `{id}`");
|
||||
};
|
||||
|
||||
let Declaration::Variable {
|
||||
location: Location::Local,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue