ossuminc / riddl

A compiler for the DDD-based design language RIDDL
https://riddl.tech/
Apache License 2.0
19 stars 6 forks source link

Handler Codependency Bug #584

Closed AlexWeinstein92 closed 3 months ago

AlexWeinstein92 commented 3 months ago

See the Riddl-examples branch for riddl code related to errors

[warning] Usage: FooBarHandlerCoDependency/Foo.riddl(1:8):
Models without any streaming data will exhibit minimal effect:
domain Foo is {
       ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(8:32):
Path Identifier Foo.InitialFoo in State 'InitialFooState' resolved to Record 'InitialFoo':
      state InitialFooState of Foo.InitialFoo is {
                               ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(10:23):
Path Identifier FooStateChange in OnMessageClause 'On command FooStateChange' resolved to Command 'FooStateChange':
           on command FooStateChange {
                      ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(11:29):
Path Identifier FooContext.Foo in OnMessageClause 'On command FooStateChange' resolved to Entity 'Foo':
              become entity FooContext.Foo to handler FooState.FinalFooState.FinalFooState
                            ^
[error] Error: FooBarHandlerCoDependency/Foo/foo.riddl(11:55):
Path 'FooState.FinalFooState.FinalFooState' was not resolved, in OnMessageClause 'On command FooStateChange'
because the PathId is invalid since it's first element, FooState, does not exist in the model
and it should refer to a Handler:
              become entity FooContext.Foo to handler FooState.FinalFooState.FinalFooState
                                                      ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(15:30):
Path Identifier Foo.FinalFooState in State 'FinalFooState' resolved to Record 'FinalFooState':
      state FinalFooState of Foo.FinalFooState is {
                             ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(17:23):
Path Identifier FooStateChange in OnMessageClause 'On command FooStateChange' resolved to Command 'FooStateChange':
           on command FooStateChange {
                      ^
[info] Info: FooBarHandlerCoDependency/Foo/foo.riddl(18:27):
Path Identifier FooContext.Foo in OnMessageClause 'On command FooStateChange' resolved to Entity 'Foo':
            become entity FooContext.Foo to handler FooState.InitialFooState.InitialFooState
                          ^
[error] Error: FooBarHandlerCoDependency/Foo/foo.riddl(18:53):
Path 'FooState.InitialFooState.InitialFooState' was not resolved, in OnMessageClause 'On command FooStateChange'
because the PathId is invalid since it's first element, FooState, does not exist in the model
and it should refer to a Handler:
            become entity FooContext.Foo to handler FooState.InitialFooState.InitialFooState
reid-spencer commented 3 months ago

The two errors resulted from use of FooState and should have just referenced the entity, Foo. Evan after correction, we still get:

[error] Error: riddlc/src/test/input/issues/584/Foo/foo.riddl(11:55):
Path 'Foo.FinalFooState.FinalFoo' was not resolved, in OnMessageClause 'On command FooStateChange'
because definition 'FinalFoo' was not found inside Record 'FinalFooState'
and it should refer to a Handler:
              become entity FooContext.Foo to handler Foo.FinalFooState.FinalFoo
                                                      ^

and

[error] Error: riddlc/src/test/input/issues/584/Foo/foo.riddl(18:53):
Path 'Foo.InitialFooState.FinalizeFoo' was not resolved, in OnMessageClause 'On command FooStateChange'
because definition 'FinalizeFoo' was not found inside Record 'InitialFoo'
and it should refer to a Handler:
            become entity FooContext.Foo to handler Foo.InitialFooState.FinalizeFoo
                                                    ^
reid-spencer commented 3 months ago

The above messages occur because the reference to Foo.FinalFootState resolves to the record type of its data content and it never finds the handler. It also needs to search the descendants of the state and not just the record type that holds the state.