fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

types declared by a type feature constructor causes `fz` to crash

Open fridis opened this issue 1 year ago • 0 comments

This small example

testxy is

  type.x => option y nil
  type.y is

either crashes fz if pre/postconditions are enabled:

 > PRECONDITIONS=true POSTCONDITIONS=true ../clean/fuzion/build/bin/fz testxy.fz

error 1: java.lang.Error: require-condition4 failed: AbstractFeature.java:873 "(res != null, Errors.any() || !isUniverse(), res.state(this).atLeast(State.FINDING_DECLARATIONS), !isTypeFeature());"
	at dev.flang.util.ANY.require(ANY.java:158)
	at dev.flang.ast.AbstractFeature.typeFeature(AbstractFeature.java:873)
	at dev.flang.ast.Feature.typeFeature(Feature.java:1300)
	at dev.flang.ast.Call.lambda$resolveTypes$20(Call.java:2498)
	at dev.flang.ast.AbstractType.applyToGenericsAndOuter(AbstractType.java:1741)
	at dev.flang.ast.Call.resolveTypes(Call.java:2491)
	at dev.flang.ast.Feature$ResolveTypes.action(Feature.java:1385)
	at dev.flang.ast.Feature$ResolveTypes.action(Feature.java:1375)
	at dev.flang.ast.Call.visit(Call.java:1206)
	at dev.flang.ast.Block.visit(Block.java:211)
	at dev.flang.ast.Block.visit(Block.java:41)
	at dev.flang.ast.Impl.visit(Impl.java:301)
	at dev.flang.ast.Feature.visit(Feature.java:1126)
	at dev.flang.ast.Feature.internalResolveTypes(Feature.java:1449)
	at dev.flang.ast.Resolution.resolveOne(Resolution.java:442)
	at dev.flang.ast.Resolution.resolve(Resolution.java:409)
	at dev.flang.fe.SourceModule.createASTandResolve(SourceModule.java:273)
	at dev.flang.fe.FrontEnd.<init>(FrontEnd.java:195)
	at dev.flang.tools.Fuzion.lambda$parseArgsForBackend$4(Fuzion.java:1069)
	at dev.flang.tools.Tool.lambda$run$0(Tool.java:142)
	at dev.flang.util.Errors.runAndExit(Errors.java:895)
	at dev.flang.tools.Tool.run(Tool.java:142)
	at dev.flang.tools.Fuzion.main(Fuzion.java:627)


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

or otherwise results in confused errors:

 > ../clean/fuzion/build/bin/fz testxy.fz

$MODULE/Any.fz:28:8: error 1: Names of arguments used in this feature must be distinct.
public Any ref is

The duplicate name is 'THIS#TYPE'
Feature with equally named arguments: 'Any'
Argument #0: 'THIS#TYPE' is duplicate 
Argument #1: 'THIS#TYPE' is duplicate 
To solve this, rename the arguments to have unique names.


/home/fridi/fuzion/work/testxy.fz:1:1: error 2: Names of arguments used in this feature must be distinct.
testxy is

The duplicate name is 'THIS#TYPE'
Feature with equally named arguments: 'testxy'
Argument #0: 'THIS#TYPE' is duplicate 
Argument #1: 'THIS#TYPE' is duplicate 
To solve this, rename the arguments to have unique names.

2 errors.

We probably have to forbid any type definitions within co-types, i.e., type features must not be constructors or choices.

fridis avatar Sep 13 '24 10:09 fridis