fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

precondition constraints not visible in qualified feature declarations

Open fridis opened this issue 1 year ago • 0 comments

A missing part of #3480: This example

test(T, U type, t T, u U) is
  constraint(Q type)
    pre
      T : String
      U : Sequence Q
  is
    show => say t.codepoint_length
            say u.count

test "㋡" [1,2,3]
  .constraint i32
  .show

works

 > ./build/bin/fz test_constraint0.fz
1
3

while the same code using a qualified declaration test.constraint.show => ...

test(T, U type, t T, u U) is
  constraint(Q type)
    pre
      T : String
      U : Sequence Q
  is

test.constraint.show => say t.codepoint_length
                        say u.count

test "㋡" [1,2,3]
  .constraint i32
  .show

does not

 > ./build/bin/fz test_constraint.fz

/home/fridi/fuzion/work/test_constraint.fz:8:31: error 1: Could not find called feature
test.constraint.show => say t.codepoint_length

Feature not found: 'codepoint_length' (no arguments)
Target feature: 'Any'
In call: 't.codepoint_length'


/home/fridi/fuzion/work/test_constraint.fz:9:31: error 2: Could not find called feature
                        say u.count

Feature not found: 'count' (no arguments)
Target feature: 'Any'
In call: 'u.count'

2 errors.

Note that this should also work in case the qualified declaration is in a different module.

fridis avatar Aug 15 '24 10:08 fridis