protected internal override void CheckSemantics(AstHelper astHelper) { VariableName.CheckSemantics(astHelper); VariableTypeName.CheckSemantics(astHelper); AstHelper childScope = VariableTypeName.HasType ? astHelper.CreateChild(expecting: true, expectedType: VariableTypeName.ReferencedType) : astHelper.CreateChild(expecting: true); Value.CheckSemantics(childScope); bool cantInferType = astHelper.Errors.Check(new CanNotInferTypeError(Type, Value.Type, Start)); astHelper.Errors.Check(new NotAssignableError(Type, Value.Type, Start)); bool memberDeclared = astHelper.Errors.Check( new MemberWithSameNameAlreadyDefinedError(VariableName.Name, astHelper, Start)); if (!memberDeclared) { if (!cantInferType) { Pointer = MAst.Parameter(Type, VariableName.Name); } else { // if the type can't be inferred then register the variable with null type Pointer = MAst.Parameter(typeof(Null), VariableName.Name); } astHelper.Variables.Add(VariableName.Name, Pointer); } }
protected internal override void CheckSemantics(AstHelper astHelper) { VariableName.CheckSemantics(astHelper); VariableTypeName.CheckSemantics(astHelper); bool memberDeclared = astHelper.Errors.Check(new MemberWithSameNameAlreadyDefinedError(VariableName.Name, astHelper, Start)); if (!memberDeclared) { Pointer = System.Linq.Expressions.Expression.Parameter(Type, VariableName.Name); astHelper.Variables.Add(VariableName.Name, Pointer); } }