Skip to content

Commit

Permalink
air: Use sourceRange(), not pos() when missing abstract implement…
Browse files Browse the repository at this point in the history
…ation

This is a preparatory patch for PR#3775. Since after #3775, only data form
modules is used and the position of an Expr is lost, only the source range is
left, the test output would change.
  • Loading branch information
fridis committed Sep 17, 2024
1 parent d7ad8ab commit 665fab8
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 42 deletions.
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
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 @@ -9,7 +9,7 @@ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1
----------^^^^^
effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1' at --CURDIR--/test_local_mutate_neg.fz:114:5:
sum l0
----^^^
----^^^^^^
effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum' at --CURDIR--/test_local_mutate_neg.fz:116:3:
test_sum
--^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions tests/reg_issue2273/reg_issue2273.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'mutate' is
----^^^^^^
Callchain that lead to this point:

effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:26:
effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:6:
d := (mutate.array door).new mutate 100 closed
-------------------------^^^
-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
effect environment '--empty--' for call to 'universe'
effect environment '--empty--' at program entry

Expand Down
4 changes: 2 additions & 2 deletions tests/reg_issue2564/reg_issue2564.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:112:5: error 1: Failed to verify that effect 'mutate' is
----^^^^^^
Callchain that lead to this point:

effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:32:
effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:8:
o := (mutate.array Any).type.new mutate
-------------------------------^^^
-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
effect environment '--empty--' for call to 'reg_issue2564'
effect environment '--empty--' at program entry

Expand Down
6 changes: 3 additions & 3 deletions tests/reg_issue3147/reg_issue3147.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature 't.type' instantiated at <source position not available>:
inherits or declares abstract feature 't.type.doit' declared at --CURDIR--/reg_issue3147.fz:25:8:
type.doit unit => abstract
-------^^^^
which is called at --CURDIR--/reg_issue3147.fz:27:23:
which is called at --CURDIR--/reg_issue3147.fz:27:21:
test(X type : t) => X.doit
----------------------^^^^
--------------------^^^^^^
without providing an implementation

Callchain that lead to this point:

call 'test#1 t' at --CURDIR--/reg_issue3147.fz:29:1:
test t
^^^^
^^^^^^
call 'universe'
program entry point

Expand Down
4 changes: 2 additions & 2 deletions tests/reg_issue3199/reg_issue3199.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature 'reg_issue3199.y' instantiated at <source position not available>:
inherits or declares abstract feature 'reg_issue3199.X.f' declared at --CURDIR--/reg_issue3199.fz:27:5:
f i32 => abstract
----^
which is called at --CURDIR--/reg_issue3199.fz:32:9:
which is called at --CURDIR--/reg_issue3199.fz:32:7:
say x.f
--------^
------^^^
without providing an implementation

Callchain that lead to this point:
Expand Down
58 changes: 29 additions & 29 deletions tests/reg_issue3359/reg_issue3359.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ Feature 'reg_issue3359.i' instantiated at --CURDIR--/reg_issue3359.fz:103:5:
inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5:
q unit => abstract
----^
which is called at --CURDIR--/reg_issue3359.fz:96:41:
which is called at --CURDIR--/reg_issue3359.fz:96:39:
if envir.args.count = 0 then v.q
----------------------------------------^
--------------------------------------^^^
and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5:
r unit => abstract
----^
which is called at --CURDIR--/reg_issue3359.fz:97:41:
which is called at --CURDIR--/reg_issue3359.fz:97:39:
else if envir.args.count = 1 then v.r
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.u#1 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3:
call 'reg_issue3359.u#2 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3:
u i
--^
--^^^
call 'reg_issue3359'
program entry point

Expand All @@ -37,22 +37,22 @@ Feature 'reg_issue3359.j' instantiated at --CURDIR--/reg_issue3359.fz:106:5:
inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5:
q unit => abstract
----^
which is called at --CURDIR--/reg_issue3359.fz:96:41:
which is called at --CURDIR--/reg_issue3359.fz:96:39:
if envir.args.count = 0 then v.q
----------------------------------------^
--------------------------------------^^^
and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5:
r unit => abstract
----^
which is called at --CURDIR--/reg_issue3359.fz:97:41:
which is called at --CURDIR--/reg_issue3359.fz:97:39:
else if envir.args.count = 1 then v.r
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.u#1 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3:
call 'reg_issue3359.u#2 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3:
u j
--^
--^^^
call 'reg_issue3359'
program entry point

Expand All @@ -66,16 +66,16 @@ Feature 'reg_issue3359.k' instantiated at --CURDIR--/reg_issue3359.fz:109:5:
inherits or declares abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5:
r unit => abstract
----^
which is called at --CURDIR--/reg_issue3359.fz:97:41:
which is called at --CURDIR--/reg_issue3359.fz:97:39:
else if envir.args.count = 1 then v.r
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.u#1 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3:
call 'reg_issue3359.u#2 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3:
u k
--^
--^^^
call 'reg_issue3359'
program entry point

Expand All @@ -88,22 +88,22 @@ Feature 'reg_issue3359.f.type' instantiated at <source position not available>:
inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10:
type.n unit => abstract
---------^
which is called at --CURDIR--/reg_issue3359.fz:54:41:
which is called at --CURDIR--/reg_issue3359.fz:54:39:
if envir.args.count = 0 then T.n
----------------------------------------^
--------------------------------------^^^
and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10:
type.o unit => abstract
---------^
which is called at --CURDIR--/reg_issue3359.fz:55:41:
which is called at --CURDIR--/reg_issue3359.fz:55:39:
else if envir.args.count = 1 then T.o
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.t#1 reg_issue3359.f' at --CURDIR--/reg_issue3359.fz:61:3:
t f
--^
--^^^
call 'reg_issue3359'
program entry point

Expand All @@ -116,22 +116,22 @@ Feature 'reg_issue3359.g.type' instantiated at <source position not available>:
inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10:
type.n unit => abstract
---------^
which is called at --CURDIR--/reg_issue3359.fz:54:41:
which is called at --CURDIR--/reg_issue3359.fz:54:39:
if envir.args.count = 0 then T.n
----------------------------------------^
--------------------------------------^^^
and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10:
type.o unit => abstract
---------^
which is called at --CURDIR--/reg_issue3359.fz:55:41:
which is called at --CURDIR--/reg_issue3359.fz:55:39:
else if envir.args.count = 1 then T.o
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.t#1 reg_issue3359.g' at --CURDIR--/reg_issue3359.fz:64:3:
t g
--^
--^^^
call 'reg_issue3359'
program entry point

Expand All @@ -144,16 +144,16 @@ Feature 'reg_issue3359.h.type' instantiated at <source position not available>:
inherits or declares abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10:
type.o unit => abstract
---------^
which is called at --CURDIR--/reg_issue3359.fz:55:41:
which is called at --CURDIR--/reg_issue3359.fz:55:39:
else if envir.args.count = 1 then T.o
----------------------------------------^
--------------------------------------^^^
without providing an implementation

Callchain that lead to this point:

call 'reg_issue3359.t#1 reg_issue3359.h' at --CURDIR--/reg_issue3359.fz:67:3:
t h
--^
--^^^
call 'reg_issue3359'
program entry point

Expand Down
4 changes: 2 additions & 2 deletions tests/reg_issue348/reg_issue348.fz.expected_err
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'reg_issue3
----^^^^^^
Callchain that lead to this point:

effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:32:
effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:10:
arr := (mutate.array a).type.new m 10 a
-------------------------------^^^
---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
effect environment '--empty--' for call to 'reg_issue348'
effect environment '--empty--' at program entry

Expand Down

0 comments on commit 665fab8

Please sign in to comment.