Skip to content

Allow zero-sized strings#930

Open
CalMorris wants to merge 1 commit intonasa:mainfrom
CalMorris:878-allow-zero-sized-strings
Open

Allow zero-sized strings#930
CalMorris wants to merge 1 commit intonasa:mainfrom
CalMorris:878-allow-zero-sized-strings

Conversation

@CalMorris
Copy link

Fixes #878

Summary

The FPP spec and the published website describe string size n as valid in the range [0, 2^31), but the compiler was rejecting string size 0 with an "invalid string size" error.

This is useful when a configured constant drives the string size and a value of 0 is used to disable a field.

Changes

  • Relax the validation in FinalizeTypeDefs.scala from size > 0 to size >= 0
  • Update the spec (Types.adoc) to document the valid range as [0,2^31-1]

Testing

Ran the existing fpp-check type test suite — all 7 tests pass, including string_size_negative (rejects -1) and string_size_too_large (rejects 0x80000000).

Relax the string size validation from `size > 0` to `size >= 0` so that
`string size 0` is accepted. This is useful when a configured constant
drives the string size and a value of 0 is used to disable a field.

Update the spec to document the valid range as [0,2^31-1], matching the
intent described on the published website.

Fixes nasa#878
@bocchino
Copy link
Collaborator

bocchino commented Mar 3, 2026

Thanks for making this PR! In order to accept this change, we will need testing, to make sure that the zero-length string case works as expected in every case. I think we will need the following:

  1. Additional tests here to test string size 0 and make sure that everything compiles: https://github.com/nasa/fpp/tree/main/compiler/tools/fpp-to-cpp/test.
  2. Additional tests here to test string size 0 and make sure that everything works as expected in F Prime: https://github.com/nasa/fprime/tree/devel/FppTestProject/FppTest.
  3. Fixes to any issues uncovered in these tests.

Ideally we would supplement every string size n test that we have with a corresponding string size 0 test. Is this something you would be willing to work on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero Sized Strings

2 participants