protected override Value?Visit(Expression.While whil) { Builder.While( condition: b => VisitNonNull(whil.Condition), body: b => Visit(whil.Body)); return(null); }
protected override object?Visit(Expression.While whil) { base.Visit(whil); // Condition must be bool var conditionType = System.TypeOf(whil.Condition); if (!conditionType.Equals(Type.Bool)) { System.Report(new ExpectedTypeError(Type.Bool, conditionType) { Context = "while condition", Place = whil.Condition.ParseTreeNode, }); } // Body must be unit var bodyType = System.TypeOf(whil.Body); if (!bodyType.Equals(Type.Unit)) { System.Report(new ExpectedTypeError(Type.Unit, bodyType) { Context = "while block", Place = FindDeepestReturnValue(whil.Body)?.ParseTreeNode, Note = "implicit returns cannot appear in while statements" }); } return(null); }