mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
fixed oversight
This commit is contained in:
parent
c32419508e
commit
8e16140b0f
@ -38,7 +38,9 @@ impl SStatementEnum {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SStatement {
|
||||
// if the statement is a Variable (is_ref == false) and it isn't dereferenced, it will be initialized. To modify a variable, it has to be is_ref.
|
||||
/// if the statement is a Variable that doesn't exist yet, it will be initialized.
|
||||
/// if it's a variable that exists, but is_ref is false, an error may show up: cannot dereference
|
||||
/// NOTE: Maybe add a bool that indicates a variable should be newly declared, shadowing old ones with the same name.
|
||||
pub output_to: Option<(Box<SStatement>, usize)>,
|
||||
pub statement: Box<SStatementEnum>,
|
||||
pub force_output_type: Option<VType>,
|
||||
|
@ -371,10 +371,9 @@ fn statement_adv(
|
||||
}
|
||||
SStatementEnum::Variable(v, is_ref) => {
|
||||
let existing_var = linfo.vars.get(v);
|
||||
// we can't assign to something that isn't a reference, so create a new variable shadowing the old one.
|
||||
// we also can't assign to a variable that doesn't exist yet, so create a new one in that case, too.
|
||||
if (!*is_ref && to_be_assigned_to.is_some()) || existing_var.is_none() {
|
||||
// if to_be_assigned_to is some (-> this is on the left side of an assignment), create a new variable. else, return an error (later).
|
||||
// we can't assign to a variable that doesn't exist yet -> create a new one
|
||||
if existing_var.is_none() {
|
||||
// if to_be_assigned_to is some (-> this is on the left side of an assignment), create a new variable. else, return an error.
|
||||
if let Some((t, is_init)) = to_be_assigned_to {
|
||||
*is_init = true;
|
||||
#[cfg(not(debug_assertions))]
|
||||
|
Loading…
Reference in New Issue
Block a user