fix comptime variable errors

This commit is contained in:
Moritz Hölting 2025-08-13 18:24:48 +02:00
parent 15dde037b7
commit e0c3253ab6
2 changed files with 21 additions and 7 deletions

View File

@ -706,13 +706,14 @@ impl Primary {
_ => false,
},
Self::MemberAccess(_) => {
// TODO:
// TODO: correct return value after check
true
}
Self::Identifier(ident) => match scope.get_variable(ident.span.str()) {
Some(VariableType::BooleanStorage) => expected == ValueType::Boolean,
Some(VariableType::ScoreboardValue) => expected == ValueType::Integer,
Some(VariableType::Tag) => expected == ValueType::String,
Some(VariableType::ComptimeValue) => true,
_ => false,
},
Self::Prefix(prefixed) => match prefixed.operator() {

View File

@ -1154,12 +1154,25 @@ impl Parser<'_> {
_ => unreachable!(),
}
}
None => Ok(VariableDeclaration::Single(SingleVariableDeclaration {
variable_type,
identifier,
assignment,
annotations: VecDeque::new(),
})),
None => {
if matches!(variable_type.keyword, KeywordKind::Val) {
Ok(VariableDeclaration::ComptimeValue(
ComptimeValueDeclaration {
val_keyword: variable_type,
identifier,
assignment,
annotations: VecDeque::new(),
},
))
} else {
Ok(VariableDeclaration::Single(SingleVariableDeclaration {
variable_type,
identifier,
assignment,
annotations: VecDeque::new(),
}))
}
}
}
}
}