Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

air: Use sourceRange(), not pos() when missing abstract implementation #3795

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dev/flang/air/AirErrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void abstractFeatureNotImplemented(AbstractFeature featureThatDoes
var afKind = af.isAbstract() ? "abstract" : "fixed";
abstracts.append((abstracts.length() == 0 ? "inherits or declares" : "and") + " " + afKind + " feature " +
s(af) + " declared at " + af.pos().show() + "\n" +
"which is called at " + clazzes.isUsedAt(af).pos().show() + "\n");
"which is called at " + clazzes.isUsedAt(af).sourceRange().show() + "\n");
}
abstracts.append("without providing an implementation\n");
error(featureThatDoesNotImplementAbstract.pos(),
Expand Down
1 change: 1 addition & 0 deletions src/dev/flang/ast/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public Expr()
* -----^^^^^^^
*
*/
@Override
public SourcePosition sourceRange()
{
return _range == null ? pos() : _range;
Expand Down
2 changes: 1 addition & 1 deletion src/dev/flang/fuir/FUIR.java
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ public SourcePosition sitePos(int s)
if (s != NO_SITE)
{
var e = getExpr(s);
result = (e instanceof Expr expr) ? expr.pos() :
result = (e instanceof Expr expr) ? expr.sourceRange() :
(e instanceof Clazz z) ? z._type.declarationPos() /* implicit assignment to argument field */
: null;
}
Expand Down
23 changes: 23 additions & 0 deletions src/dev/flang/util/HasSourcePosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ public interface HasSourcePosition
*/
SourcePosition pos();


/**
* Source range of this Expr. Note that this might be longer than the Expr
* itself, e.g., in a call
*
* f (x.q y)
*
* The argument to f is the call `x.q y` whose position is
*
* f (x.q y)
* --------^
*
* but the source range is
*
* f (x.q y)
* -----^^^^^^^
*
*/
default SourcePosition sourceRange()
{
return pos();
}

}

/* end of file */
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Feature 'abstractfeatures_negative.opengenerics12.G' instantiated at --CURDIR--/
inherits or declares abstract feature 'abstractfeatures_negative.opengenerics12.F.f' declared at --CURDIR--/abstractfeatures_negative.fz:33:7:
f(a A) is abstract // 1. should flag an error: abstract feature not implemented
------^
which is called at --CURDIR--/abstractfeatures_negative.fz:40:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:40:19:
if maybe then y.f 3 true 5
--------------------^
------------------^^^^^^^^^^^^
without providing an implementation

Callchain that lead to this point:
Expand All @@ -31,21 +31,21 @@ Feature 'abstractfeatures_negative.opengenerics12a.G' instantiated at --CURDIR--
inherits or declares abstract feature 'abstractfeatures_negative.opengenerics12a.F.f1' declared at --CURDIR--/abstractfeatures_negative.fz:46:7:
f1(a A) is abstract // 3. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:56:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:56:19:
if maybe then y.f1 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
and abstract feature 'abstractfeatures_negative.opengenerics12a.F.f2' declared at --CURDIR--/abstractfeatures_negative.fz:47:7:
f2(a A) is abstract // 4. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:57:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:57:19:
if maybe then y.f2 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
and abstract feature 'abstractfeatures_negative.opengenerics12a.F.f3' declared at --CURDIR--/abstractfeatures_negative.fz:48:7:
f3(a A) is abstract // 5. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:58:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:58:19:
if maybe then y.f3 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
without providing an implementation

Callchain that lead to this point:
Expand All @@ -66,9 +66,9 @@ Feature 'abstractfeatures_negative.opengenerics12b.G' instantiated at --CURDIR--
inherits or declares abstract feature 'abstractfeatures_negative.opengenerics12b.F.f' declared at --CURDIR--/abstractfeatures_negative.fz:64:7:
f(a A) is abstract // 7. should flag an error: abstract feature not implemented
------^
which is called at --CURDIR--/abstractfeatures_negative.fz:70:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:70:19:
if maybe then x.f 3 true 5
--------------------^
------------------^^^^^^^^^^^^
without providing an implementation

Callchain that lead to this point:
Expand All @@ -89,21 +89,21 @@ Feature 'abstractfeatures_negative.opengenerics12c.G' instantiated at --CURDIR--
inherits or declares abstract feature 'abstractfeatures_negative.opengenerics12c.F.f1' declared at --CURDIR--/abstractfeatures_negative.fz:76:7:
f1(a A) is abstract // 9. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:85:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:85:19:
if maybe then x.f1 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
and abstract feature 'abstractfeatures_negative.opengenerics12c.F.f2' declared at --CURDIR--/abstractfeatures_negative.fz:77:7:
f2(a A) is abstract // 10. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:86:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:86:19:
if maybe then x.f2 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
and abstract feature 'abstractfeatures_negative.opengenerics12c.F.f3' declared at --CURDIR--/abstractfeatures_negative.fz:78:7:
f3(a A) is abstract // 11. should flag an error: abstract feature not implemented
------^^
which is called at --CURDIR--/abstractfeatures_negative.fz:87:21:
which is called at --CURDIR--/abstractfeatures_negative.fz:87:19:
if maybe then x.f3 3 true 5
--------------------^^
------------------^^^^^^^^^^^^^
without providing an implementation

Callchain that lead to this point:
Expand Down
Loading