Пример #1
0
        public override object VisitAssignmentStatement([NotNull] AssignmentStatementContext context)
        {
            var pathType       = TypeVisitor.GetType(context.path(), scope, errors);
            var expressionType = TypeVisitor.GetType(context.expression(), scope, errors) ?? TypeSystem.Instance["ErrorType"];

            if (pathType == TypeSystem.Instance["AnyType"])
            {
                return(base.VisitAssignmentStatement(context));
            }

            if (pathType != TypeSystem.Instance["ErrorType"] && !expressionType.InheritsFrom(pathType))
            {
                errors.Add(new Error(context.expression(), $"Type mismatch: {expressionType} cannot be assigned to {pathType}."));
            }

            return(base.VisitAssignmentStatement(context));
        }
Пример #2
0
 public override void ExitAssignmentStatement(AssignmentStatementContext context)
 {
     AppendLine(";");
 }