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

fast-dds-gen-3.3.0 with idl-parser 3.0.0 : idl parse error observed when idl contains a struct which references an array typedef [21343] #373

Closed
srchaitu2008 opened this issue Jul 10, 2024 · 6 comments · Fixed by #374

Comments

@srchaitu2008
Copy link

srchaitu2008 commented Jul 10, 2024

The below mentioned idl file parsing fails with below mentioned error (idl-parser 3.0.0 is used alongwith fast-dds-gen 3.3.0) :

IDL file:

module module1
{
enum mod1_enum_val
{
value1, //1
value2 //2
}; //mod1_enum_val
}; //module1
const module1::mod1_enum_val enum1 = module1::mod1_enum_val::value1;
typedef string StringU;
typedef int32 IntArray[23];
struct SampleStruct
{
StringU stringU;
IntArray ArrayInt32;
}; //SampleStruct

Error:

Processing the file /tmp/IdlParseError.idl...
/tmp/IdlParseError.idl:11:26: error: Error evaluating array dimension: ;enum1=module1::mod1_enum_val::value1;enum1=module1::mod1_enum_val::value1;(23) | 0
/tmp/IdlParseError.idl:15:3: error: 'IntArray' was not defined previously

In the above idl file, there is a struct which tries to declare an int array as typedef. One observation is that when the enum declaration (const module1::mod1_enum_val enum1 = module1::mod1_enum_val::value1;) is removed/commented, the parsing works fine.

Below command is used :

<Path to java11 exe> -jar <path to fastddsgen.jar> -replace -ppDisable -d <path to folder where files should be generated> <path to IdlParseError.idl file>

For example:

"/home/user/java11/jre/bin/java" -jar "/home/user/fastddsgen.jar" -replace -ppDisable -d "/home/user/SampleFolder" "/home/user/IdlParseError.idl"

@srchaitu2008
Copy link
Author

Additionally, please check the below IDL file as well:

module Top
{
const uint32 MAXLEN = 64;
const uint32 SeqLenAssumingThisModule = MAXLEN;
const uint32 SeqLen = Top::MAXLEN;
}; //Top
struct Sub
{
int32 userID;
double f64Data;
uint8 vChar;
}; //Sub
typedef Sub SubSequence[Top::SeqLen];
struct AllSubs
{
SubSequence Subs;
}; //AllSubs

Similar error is encountered:

Processing the file /tmp/IdlParseError_2.idl...
/tmp/IdlParseError_2.idl:13:36: error: Error evaluating array dimension: ;Top_MAXLEN=64;Top_SeqLenAssumingThisModule=MAXLEN;Top_SeqLen=Top::MAXLEN;(Top_SeqLen) | 0
/tmp/IdlParseError_2.idl:16:3: error: 'SubSequence' was not defined previously

@richiware
Copy link
Member

Thanks for the report. We will take it into a look.

@richiware richiware changed the title fast-dds-gen-3.3.0 with idl-parser 3.0.0 : idl parse error observed when idl contains a struct which references an array typedef fast-dds-gen-3.3.0 with idl-parser 3.0.0 : idl parse error observed when idl contains a struct which references an array typedef [21343] Jul 11, 2024
@srchaitu2008
Copy link
Author

Hi @richiware ,

I have tried the fix and the previously mentioned IDL files are processing successfully.

Given below is another IDL file for which the processing fails with this fix as well:

module module1
{
enum mod1_enum_val
{
value1,
value2
}; //mod1_enum_val
}; //module1
const int32 myValUsingFullPathAsInt32 = module1::mod1_enum_val::value1;
const module1::mod1_enum_val myValUsingFullPath = module1::mod1_enum_val::value1;
const module1::mod1_enum_val myVal = module1::mod1_enum_val::value2;
module Top
{
const uint32 MAXLEN = 64;
const uint32 SeqLenAssumingThisModule = MAXLEN;
const uint32 SeqLen = Top::MAXLEN;
}; //Top
struct Sub
{
int32 userID;
double f64Data;
uint8 vChar;
}; //Sub
enum Modes
{
MODE1, //11
MODE2, //20
MODE3 //200
}; //Modes
const int32 myDefaultModeAsInt32 = Modes::MODE3;
const Modes myDefaultMode = Modes::MODE3;
const Modes myDefaultMode1 = Modes::MODE2;
typedef Sub SubSequence[Top::SeqLen];
struct AllSubs
{
SubSequence Subs;
}; //AllSubs

Error

Processing the file /tmp/IdlError3.idl...
/tmp/IdlError3.idl:9:70: error: Error evaluating expression: ;(module1_mod1_enum_val_value1) | 0
/tmp/IdlError3.idl:30:47: error: Error evaluating expression: ;Top_MAXLEN=64;Top_SeqLenAssumingThisModule=64;Top_SeqLen=64;(Modes_MODE3) | 0

Requesting you to take a look at this as well.

@srchaitu2008
Copy link
Author

srchaitu2008 commented Jul 15, 2024

Hi @richiware ,

Can you please take a look at the above IDL file as well?

@richiware
Copy link
Member

I was testing your last IDL file. The failure is caused by the integer constant that is set with a enumeration value. This corner case will be more difficult to be supported and right now I don't have that time.

I propose you to open a new issue for this new case and we will fix it when we have time and this issue could be closed automatically when the related PR are merged.

@srchaitu2008
Copy link
Author

Hi @richiware ,

As requested in earlier comments, raised issue 385 for IDL parse error when integer constant is set with enum value.

Thanking you,
S.Ravi.Chaitanya

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 a pull request may close this issue.

2 participants