fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Initial value not allowed for feature not embedded in outer feature

Open michaellilltokiwa opened this issue 2 years ago • 2 comments

This error happens when defining a 'top-level' field e.g. my_field in e.g. lib/io/file.fz. The outer feature should here be io. So the feature would be io.my_field and thus have an outer feature.

michaellilltokiwa avatar May 23 '23 11:05 michaellilltokiwa

This is forbidden since this it is undefined in which order such fields should be initialized causing ambiguity as in

file a.fz:

  m1 := time.nano.read

file b.fz:

  m2 := time.nano.read
  if m1 < m2 then panic "should this panic?"

Unless there is a very good reason, I would like to avoid ambiguity like this. Introducing some hidden logic (like using the file names in alphabetical order) would probably not be a nice solution.

fridis avatar May 24 '23 06:05 fridis

That makes sense. But the error message is misleading then, so I'm leaving this open for improving the error message.

michaellilltokiwa avatar May 24 '23 07:05 michaellilltokiwa