[Jastadd] [Q] unknown type ?
Hello JastAddJ developers,
In Java1.4Frontend/TypeCheck.jrag, the following line exists:
syn TypeDecl AssignExpr.sourceType() =
getSource().type().isPrimitive() ? getSource().type() : unknownType();
which means the source type of an assign expression is the unknown type
unless it is a primitive type.
Why should it be?
and the AssignSimpleExpr.typeCheck() is written as follows:
public void AssignSimpleExpr.typeCheck() {
if(!getDest().isVariable())
error("left hand side is not a variable");
else if(!sourceType().assignConversionTo(getDest().type(), getSource())
&& !sourceType().isUnknown())
error("can not assign " + getDest() + " of type " +
getDest().type().typeName() +
" a value of type " + sourceType().typeName());
}
This means that, if the source type is unknown, it is not an error even when
the source type is not assign-compatible
with the destination type for a simple assignment.
It is hard for me to figure out what's going on here.
Why do you introduce the unknown type during the type checking process?
- Hyunik
Received on Wed Dec 21 2011 - 10:37:06 CET
This archive was generated by hypermail 2.3.0
: Wed Apr 16 2014 - 17:19:06 CEST