vhdl: partial impl of const decl typeval
Partially implement the type evaluation of constant declarations. This
triggers type evaluation of the initial expression, which is a good
starting point to sort out the entire expression parsing and type
evaluation business.
@@ -43,8 +43,16 @@ impl<'sbc, 'lazy, 'sb, 'ast, 'ctx> AddContext<'sbc, 'lazy, 'sb, 'ast, 'ctx> {
}));
mk.typeval(Box::new(move |tyc|{
let hir = tyc.ctx.lazy_hir(id)?;
+ let ty = tyc.lazy_typeval(hir.decl.ty)?;
+ if let Some(init) = hir.decl.init {
+ let init_ty = tyc.lazy_typeval(init)?;
// TODO: Check that the type of the init expression matches.
- tyc.ctx.lazy_typeval(hir.decl.ty)
+ tyc.emit(
+ DiagBuilder2::note(format!("const has type `{}`, init has type `{}`", ty, init_ty))
+ .span(hir.span)
+ );
+ }
+ Ok(ty)
}));
Ok(mk.finish().into())
}).collect()
