Improve: allow type declarations before variable definitions

This commit is contained in:
Shunsuke Shibayama 2022-12-25 01:36:41 +09:00
parent ee04d96487
commit b8e575ea99
3 changed files with 224 additions and 99 deletions

View file

@ -403,7 +403,11 @@ impl Context {
input: &Input,
namespace: &Str,
) -> SingleTyCheckResult<VarInfo> {
if let Some(vi) = self.decls.get(&ident.inspect()[..]) {
if let Some(vi) = self
.decls
.get(&ident.inspect()[..])
.or_else(|| self.future_defined_locals.get(&ident.inspect()[..]))
{
match self.validate_visibility(ident, vi, input, namespace) {
Ok(()) => {
return Ok(vi.clone());