halcompile: warn about, and reject colliding, mangled HAL names - #4298
halcompile: warn about, and reject colliding, mangled HAL names#4298tzuohann wants to merge 1 commit into
Conversation
ea6413a to
e1db816
Compare
|
Name collisions are bad by default and fail to compile. Why is there an option for this? You should be able to check this much easier using a parallel name array for target names (which you apparently do) without complex regexes or lambdas by using a simple Your second PR seems to be a duplicate and changes a generated (man) file that is not part of the repository. Why is this submitted twice? |
It's a 2.9 backport, no .adoc there, also threw me off... |
|
thanks. help me understand here. is this is a problem that can throw some people (amateurs using AI) off? if so and a little fix can help, I'll try to sharpen the solution. but if its not even an issue, i'll close the PR. |
A name declared in a .comp file is a C identifier, but it is exported
under a mangled HAL identifier: underscores become dashes and a trailing
dash or period is removed (comp.adoc, HALNAME). Nothing said so at
compile time, so "pin in float my_input" silently became
component.N.my-input.
Worse, check_name_ok() compares only declared names. Two declarations
that mangle to the same HAL name -- x_y and x_y_, the two rows of the
HALNAME table that share a HAL identifier -- therefore compiled cleanly
and failed much later, at load time:
HAL: ERROR: duplicate variable 'collide.0.x-y'
collide: rtapi_app_main: Invalid argument (-22)
Add check_hal_name(), which rejects that collision at the offending
line, and a once-per-file warning listing the names whose HAL identifier
differs from the declaration. Both messages point at the HALNAME
documentation. The warning is suppressed by -N (--no-name-warnings),
which the in-tree component rules pass, since those names are deliberate.
All 133 in-tree .comp files preprocess with no new error, and silently
under -N. tests/halcompile/halname covers the warning, -N, and the
rejected collision.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
e1db816 to
1188057
Compare
But they actually don't, I tested the claimed Edit: |
|
Simplified as you suggested: two dicts (pins+params, functions) and Also fixed while checking this: array names were listed as mangled even without an underscore, since #4299 is the 2.9 backport, not a duplicate. |
pin in float my_inputis exported ascomponent.N.my-input— underscores become dashes (comp.adoc, HALNAME).A component that declares both
x_yandx_y_exports both asx-y. halcompile accepts it; the module then fails at loadrt:check_name_ok()only compares declared names.check_hal_name()errors on the collision at the offending line, and a once-per-file warning lists names whose HAL identifier differs.-Nsuppresses the warning only, never the error; the in-tree rules pass it so build output is unchanged.Docs: NAMES section in the halcompile man page, note under the HALNAME table in comp.adoc. Tests:
tests/halcompile/halname. All 133 in-tree.compfiles preprocess with no new error.Backport for 2.9: #4299.
🤖 Generated with Claude Code