Skip to content

Variable declaration rules #657

@onbjerg

Description

@onbjerg

Describe the feature

We currently do not have most of the checks for variable declarations in https://github.com/argotorg/solidity/blob/73712a01b2de56d9ad91e3b6936f85c90cb7de36/libsolidity/analysis/TypeChecker.cpp#L475-L596

We need to implement these. The entrypoint for this is in

#[must_use]
fn check_var_(&mut self, id: hir::VariableId, expect: bool) -> Ty<'gcx> {
let var = self.gcx.hir.variable(id);
let _ = self.visit_ty(&var.ty);
let ty = self.gcx.type_of_item(id.into());
if let Some(init) = var.initializer {
// TODO: might have different logic vs assignment
self.check_assign(ty, init);
if expect {
let _ = self.expect_ty(init, ty);
}
}
// TODO: checks from https://github.com/ethereum/solidity/blob/9d7cc42bc1c12bb43e9dccf8c6c36833fdfcbbca/libsolidity/analysis/TypeChecker.cpp#L472
ty
}

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-semaArea: semantic analysisC-enhancementCategory: an issue proposing an enhancement or a PR with one

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions