mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
fixes
This commit is contained in:
parent
cde20ce7ae
commit
963404d32d
3 changed files with 24 additions and 3 deletions
|
|
@ -333,8 +333,15 @@ impl<'o> WalkProc<'o> {
|
|||
}
|
||||
if let Some(var_type) = var_type {
|
||||
self.visit_var(location, var_type, key, None);
|
||||
self.visit_var(location, var_type, value, None);
|
||||
}
|
||||
// the "v" in a DM for (var/k, v) statement is essentially typeless.
|
||||
// There is currently no way to change that.
|
||||
let var_type_value = VarType {
|
||||
flags: VarTypeFlags::from_bits_truncate(0),
|
||||
type_path: Box::new([]),
|
||||
input_type: InputType::from_bits_truncate(0),
|
||||
};
|
||||
self.visit_var(location, &var_type_value, value, None);
|
||||
self.visit_block(block);
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,3 +94,17 @@ fn for_loop_condition() {
|
|||
"##.trim();
|
||||
check_errors_match(code, FOR_LOOP_CONDITION_ERRORS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn for_kv_check() {
|
||||
let code = r##"
|
||||
/proc/test()
|
||||
var/alist/A = alist()
|
||||
for (var/k, v in A)
|
||||
world.log << k
|
||||
world.log << v
|
||||
|
||||
"##.trim();
|
||||
check_errors_match(code, NO_ERRORS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1460,7 +1460,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
|
|||
// this is a really terrible way to do this
|
||||
Some(Statement::Var(var_statement)) => match var_statement.value {
|
||||
None => (Some(var_statement.var_type), var_statement.name),
|
||||
_ => return Err(self.error("cannot assigned a value in var/key for(var/key, value) statement")),
|
||||
_ => return Err(self.error("cannot assigned a value to var/key in a for(var/key, value) statement")),
|
||||
},
|
||||
_ => return Err(self.error("for (var/key, value) requires a 'var' keyword")),
|
||||
};
|
||||
|
|
@ -1468,7 +1468,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
|
|||
// It should also pass only if it's an ident
|
||||
let value = match lhs.into_term() {
|
||||
Some(Term::Ident(value)) => value,
|
||||
_ => return Err(self.error("value must be a variable in for (var/key, value) statement")),
|
||||
_ => return Err(self.error("value must be a variable in a for (var/key, value) statement")),
|
||||
};
|
||||
// TODO : check if `x` is an ident/a "list()" or "alist()" statement ?
|
||||
require!(self.exact(Token::Punct(Punctuation::RParen)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue