Repository navigation
Fix fpp-to-cpp dropping rational format fields on aliases of F32 and F64 - #1119
Merged
bocchino merged 1 commit intoSep 21, 2026
Merged
Conversation
When a telemetry channel, event parameter, struct member, or array element
is declared with a type alias whose underlying type is F32 or F64, the C++
writer dropped the rational format field and emitted the default %f.
Semantic checking already resolves the alias, so `type T = F32` with a
format of `{.3e}` passes the checks and then generates `%f`: the precision
and the conversion are silently lost.
FormatCppWriter.writeField dispatched the rational case on the syntax of
the type name node rather than on the type it denotes, so an alias name
never matched Ast.TypeNameFloat. The integer case already dispatched on
the underlying type; do the same for the rational case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
FormatCppWriter.writeFielddispatched the rational (floating-point) format case on the syntax of the type-name node, so a type alias whose underlying type isF32orF64never matchedAst.TypeNameFloatand fell through to the default%f. The integer case already dispatched on the denoted type; this change does the same for the rational case, resolving the alias before selecting the conversion. No FPP or interface change.Also:
alias_type.fppundercompiler/tools/fpp-to-cpp/test/array, exercising an array element whose type is anF32alias with a rational format, plus the regenerated reference outputs (ATF32AliasAc,AliasTypeFormatArrayAc) and therun.sh/update-ref.shupdates that include it.Rationale
Fixes #1116. With
type ATF32 = F32and a format of{.3e}, semantic checking resolves the alias and accepts the format, butfpp-to-cppthen emittedtmp.format("%f", ...)instead of"%.3e": the precision and theeconversion were silently dropped, while the same array declared withF32directly produced"%.3e".Testing/Review Recommendations
alias_type.fppreference outputs now show%.3ewhere the old code produced%f; with onlyFormatCppWriter.scalareverted and the test kept, the reference comparison fails on exactly that difference.FormatCppWriter.scala, reusing the dispatch the integer case already does.Future Work
None.
AI Usage (see policy)
This contribution comes out of a defect-hunting pipeline I build and run (Dev-next-gen). It uses Claude Code with Anthropic's Claude Opus 5.
FormatCppWriter.scala, the newalias_type.fppcase and its regenerated reference outputs undercompiler/tools/fpp-to-cpp/test/array.fpp-to-cppcode generation for cases where a resolved type alias is treated differently from its underlying type, and found the rational format field dropped on aliases ofF32/F64while the integer case handled them.IAMAI
"Nothing this pipeline produces is submitted without human approval. The entire pull request — the code change, the test case and its reference outputs, and this description — was reviewed by a human before the pipeline was allowed to submit it."
(@Dev-next-gen)