Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for invalid use of Trice0/Trice #464

Closed
KammutierSpule opened this issue May 16, 2024 · 10 comments
Closed

check for invalid use of Trice0/Trice #464

KammutierSpule opened this issue May 16, 2024 · 10 comments

Comments

@KammutierSpule
Copy link

Trice0( variable ); // invalid use
Trice0( "tex %u", variable ); // invalid use

Should the trice tool flag this invalid usage of the Trice0 ?

@rokath
Copy link
Owner

rokath commented May 16, 2024

Usually you do not need to put the parameters count into the trice name. Trice0( is as good as Trice( when compiling with at least c99. See also issue #279. The code snippets you showed do not contain iD(123). I would expect the compiler to complain about that. If you run trice i, the trice tool should insert the IDs. Then you'll compile and if you dislike the IDs in the code, you can remove them with trice c afterwards until next compilation.

@KammutierSpule
Copy link
Author

The use of Trice0 is related to #452 issue (compile on C++)

Trice0( variable ); // invalid use
Trice0( "tex %u", variable ); // invalid use

On these cases, trice insert is not giving an ID or report any message. it should report this mistake.

@rokath
Copy link
Owner

rokath commented May 16, 2024

Such trice tool check is a good idea, but it would need an additional parsing which would slow down the whole process. Also it is no solution for the limits of the current parsing because some other weird sequence could occur as well. I assume, that the compiler anyway will complain about missing IDs and the developers will be able to fix the code.

@KammutierSpule
Copy link
Author

Actually what was happening to me was something like:
Initial state:

Trice0( variable ); // invalid use
Trice0 ( "Good Trice\r\n" );

trice insert

Trice0( id(id), variable ); // No compiler complain ( don't mind id vs ID vs Id vs iD)
Trice0 (  id(id), "Good Trice\r\n" );

trice clean

Trice0( variable );
Trice0 (  id(id), "Good Trice\r\n" ); // it keeps the previous if, no clean

I'm not sure if this was the sequence but somehow it ended with "orphan" ID's.
I detected that because I was getting unknown Ids in the code (after I manually clean the json files)

@rokath
Copy link
Owner

rokath commented May 17, 2024

The inserted IDs are expected to be iD(123) and not id(123) in the shown case.

@rokath
Copy link
Owner

rokath commented May 17, 2024

When you clean the til.json file you need execute trice i afterwards, before you compile.

@KammutierSpule
Copy link
Author

KammutierSpule commented May 17, 2024

I just tested this, started from a empty li.json/til.json

void trice0_test() {
    Trice0( "OK");
    Trice( InvalidUse );
    Trice( "OK", Variable );
}

Then I run trice insert

void trice0_test() {
    Trice0( iD(2740), "OK"); // ok, iD is added
    Trice( InvalidUse ); // no warning or error
    Trice( "OK", Variable ); // id is not added / updated
}

@KammutierSpule KammutierSpule changed the title check for invalid use of Trice0 check for invalid use of Trice0/Trice May 17, 2024
@rokath
Copy link
Owner

rokath commented May 17, 2024

Yes, that is consistent wrong.

@rokath
Copy link
Owner

rokath commented May 19, 2024

In https://github.com/rokath/trice/blob/master/docs/TriceUserGuide.md#922-linited-trice-parser-capabilities there is now this documented as limitation. I close this issue now as we still have #465 and a separate check makes not much sense as explained.

@rokath rokath closed this as completed May 19, 2024
@rokath
Copy link
Owner

rokath commented Aug 17, 2024

The use of Trice0 is related to #452 issue (compile on C++)

Trice0( variable ); // invalid use
Trice0( "tex %u", variable ); // invalid use

On these cases, trice insert is not giving an ID or report any message. it should report this mistake.

The 2nd example would be covered on solving issue #150.

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

No branches or pull requests

2 participants