Skip to content

Commit

Permalink
Improve compiler error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed May 25, 2023
1 parent 82ea566 commit 598c8f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -656,15 +656,19 @@ else if (fConditional)

exprRightNew = exprRight.validateMulti(ctxRValue, atypeReq, errs);

if (fValid)
if (exprRightNew == null)
{
merge(ctxRValue, ctxLValue);
fValid = false;
}

// conditional expressions can update the LVal type from the RVal type, but the
// initial boolean is discarded
if (exprRightNew != null)
else
{
// conditional expressions can update the LVal type from the RVal type,
// but the initial boolean is discarded
if (fValid)
{
merge(ctxRValue, ctxLValue);
}

exprLeft.markAssignment(ctxRValue,
fConditional && exprRight != null && exprRight.isConditionalResult(), errs);

Expand Down
8 changes: 5 additions & 3 deletions javatools/src/main/java/org/xvm/compiler/ast/AstNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -1359,9 +1359,11 @@ else if (typeParam != null && !errsTemp.hasSeriousErrors())

log(errsTemp, Severity.ERROR, Compiler.INCOMPATIBLE_PARAMETER_TYPE,
String.valueOf(i+1), method.getParam(i).getName(),
method.getIdentityConstant().getValueString(),
typeParam.getValueString(),
typeExpr == null ? exprArg.toString() : typeExpr.getValueString());
method.getIdentityConstant().getSignature().removeAutoNarrowing().getValueString(),
typeParam.removeAutoNarrowing().getValueString(),
typeExpr == null
? exprArg.toString()
: typeExpr.removeAutoNarrowing().getValueString());
}

if (typeParam != null)
Expand Down
3 changes: 0 additions & 3 deletions lib_ecstasy/src/main/x/ecstasy/lang/src/Parser.x
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,6 @@ class Parser
return True, token;
}

// TODO GG - small error (pass parser instead of lexer) results in hard to read errors ...
// maybe report one error, then make a guess at which method was trying to be called?
// if ((Token left, Token right) := token.peel(id, this))
if ((Token left, Token right) := token.peel(id, lexer))
{
matchedToken = left;
Expand Down

0 comments on commit 598c8f8

Please sign in to comment.