fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

`Fixed feature is not implemented` error reports wrong call site

Open fridis opened this issue 2 years ago • 1 comments

This example taken from #795

test_fixed is

  a is
    fixed x => say "in a.x"

  b : a is

  a.x
  p ref a := b
  p.x      # should cause an error

correctly reports an error:

 > ./build/bin/fz test_fixed.fz

/home/fridi/fuzion/work/test_fixed.fz:6:3: error 1: Used fixed feature 'test_fixed.a.x' is not implemented by 'test_fixed.b'
  b : a is
--^
Feature 'test_fixed.b' instantiated at /home/fridi/fuzion/work/test_fixed.fz:9:14:
  p ref a := b
-------------^
inherits or declares fixed feature 'test_fixed.a.x' declared at /home/fridi/fuzion/work/test_fixed.fz:4:5:
    fixed x => say "in a.x"
----^
which is called at /home/fridi/fuzion/work/test_fixed.fz:8:5:
  a.x
----^
without providing an implementation

one error.

But at the end, reports a.x as the faulty call, while this shoud be p.x.

fridis avatar Mar 16 '23 16:03 fridis

test_fixed is

  a ref is
    fixed x => say "in a.x"

  b : a is

  a.x
  p a := b
  p.x      # should cause an error

now causes a NPE

rror 1: java.lang.NullPointerException: Cannot invoke "dev.flang.ast.AbstractFeature.redefinesFull()" because "result" is null
        at dev.flang.air.Clazz.findRedefinition(Clazz.java:1040)
        at dev.flang.air.Clazz.lookup(Clazz.java:1237)
        at dev.flang.air.Clazz.lookup(Clazz.java:1157)
        at dev.flang.air.Clazz.lookup(Clazz.java:1135)
        at dev.flang.air.Clazz.lookupIfInstantiated(Clazz.java:1001)
        at dev.flang.air.Clazz.lambda$findAllClasses$4(Clazz.java:1594)
        at dev.flang.air.Clazzes.whenCalledDynamically(Clazzes.java:509)
        at dev.flang.air.Clazz.findAllClasses(Clazz.java:1594)
        at dev.flang.air.Clazzes.findAllClasses(Clazzes.java:474)
        at dev.flang.fuir.FUIR.<init>(FUIR.java:187)
        at dev.flang.opt.Optimizer.fuir(Optimizer.java:73)
        at dev.flang.tools.Fuzion$Backend.processFrontEnd(Fuzion.java:506)
        at dev.flang.tools.Fuzion.lambda$parseArgsForBackend$4(Fuzion.java:1071)
        at dev.flang.tools.Tool.lambda$run$0(Tool.java:142)
        at dev.flang.util.Errors.runAndExit(Errors.java:878)
        at dev.flang.tools.Tool.run(Tool.java:142)
        at dev.flang.tools.Fuzion.main(Fuzion.java:626)


*** fatal errors encountered, stopping.
one error.

michaellilltokiwa avatar Aug 21 '24 10:08 michaellilltokiwa

It currently does not cause any errors at all, p.x just prints in a.x.

simonvonhackewitz avatar Oct 11 '24 09:10 simonvonhackewitz

p ref a := b is not possible anymore. closing.

michaellilltokiwa avatar Nov 15 '24 11:11 michaellilltokiwa