fix comptime variable errors
This commit is contained in:
parent
15dde037b7
commit
e0c3253ab6
|
@ -706,13 +706,14 @@ impl Primary {
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
Self::MemberAccess(_) => {
|
Self::MemberAccess(_) => {
|
||||||
// TODO:
|
// TODO: correct return value after check
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Self::Identifier(ident) => match scope.get_variable(ident.span.str()) {
|
Self::Identifier(ident) => match scope.get_variable(ident.span.str()) {
|
||||||
Some(VariableType::BooleanStorage) => expected == ValueType::Boolean,
|
Some(VariableType::BooleanStorage) => expected == ValueType::Boolean,
|
||||||
Some(VariableType::ScoreboardValue) => expected == ValueType::Integer,
|
Some(VariableType::ScoreboardValue) => expected == ValueType::Integer,
|
||||||
Some(VariableType::Tag) => expected == ValueType::String,
|
Some(VariableType::Tag) => expected == ValueType::String,
|
||||||
|
Some(VariableType::ComptimeValue) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
Self::Prefix(prefixed) => match prefixed.operator() {
|
Self::Prefix(prefixed) => match prefixed.operator() {
|
||||||
|
|
|
@ -1154,12 +1154,25 @@ impl Parser<'_> {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Ok(VariableDeclaration::Single(SingleVariableDeclaration {
|
None => {
|
||||||
variable_type,
|
if matches!(variable_type.keyword, KeywordKind::Val) {
|
||||||
identifier,
|
Ok(VariableDeclaration::ComptimeValue(
|
||||||
assignment,
|
ComptimeValueDeclaration {
|
||||||
annotations: VecDeque::new(),
|
val_keyword: variable_type,
|
||||||
})),
|
identifier,
|
||||||
|
assignment,
|
||||||
|
annotations: VecDeque::new(),
|
||||||
|
},
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Ok(VariableDeclaration::Single(SingleVariableDeclaration {
|
||||||
|
variable_type,
|
||||||
|
identifier,
|
||||||
|
assignment,
|
||||||
|
annotations: VecDeque::new(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue