Better error messages - from reddit

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Mar 5 06:33:33 UTC 2019


On Tue, Mar 05, 2019 at 01:49:26AM +0000, Nicholas Wilson via Digitalmars-d wrote:
> On Tuesday, 5 March 2019 at 01:18:05 UTC, H. S. Teoh wrote:
[...]
> > But to take care of the most common case, all we have to do is to
> > assume that sig constraints are of the form (A && B && C && ...).
> > The compiler only needs to report which of these top level conjuncts
> > failed.  If a sig constraint isn't of this form, then fallback to
> > reporting the entire constraint as failed, i.e., treat it as the
> > case (A) (single-argument conjunction).
> 
> You don't actually get (A && B && C && ...) you get (A && (B && (C &&
> ...))) (at least I think thats what you get I haven't been able to
> confirm the exact AST) each of which could contain arbitrary
> conjugation, so you need to recurse and that hurts my head.
[...]

(A && (B && (... ))) is pretty standard AST structure for representing a
list of conjunctions.  I don't think we need to worry about non-linear
trees of &&'s, we just have to deal with the common case of
right-recursion in the AST, so just traverse down the right child of
each && node and the corresponding left subtrees would be the major
"clauses" of the sig constraint.  That's probably good enough for a
first stab at the problem.


T

-- 
Leather is waterproof.  Ever see a cow with an umbrella?


More information about the Digitalmars-d mailing list