nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
49 stars 31 forks source link

Revise semantic checking of serial port connections #208

Closed bocchino closed 1 year ago

bocchino commented 1 year ago

Closes #183.

tiffany1618 commented 1 year ago

Should we also be excluding the case where a typed output port with a return type is connected to a serial input port?

bocchino commented 1 year ago

Yes, that sounds right. What happens in this case in the current implementation? Does the code even compile?

tiffany1618 commented 1 year ago

I think the expected behavior is to have an assertion fail on a nullptr, but currently it seg faults when FW_PORT_SERIALIZATION is defined. Here is the code that's generated:

https://github.com/fprime-community/fpp/blob/d55f67d48c8fe01994bd1abddd47974e98ab6667/compiler/tools/fpp-to-cpp/test/port/ReturnTypePortAc.ref.cpp#L110-L115

Maybe we should remove lines 110-112 for ports with return types.

bocchino commented 1 year ago

Maybe we should remove lines 110-112 for ports with return types.

Yes, that sounds right. Also, we should systematically replace FW_ASSERT(ptr) with FW_ASSERT(ptr != nullptr). C++ does not guarantee that nullptr == 0.

bocchino commented 1 year ago

OK, I revised the PR to exclude both serial -> typed and typed -> serial when the port type has a return type.