lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
230 stars 62 forks source link

Errors when using string data type #1204

Open byeonggiljun opened 2 years ago

byeonggiljun commented 2 years ago

A strange syntax error occurs when I try to put the input array to the reactor. image Types of receive and s.in are input[N] ~:string. This is the code's link. https://github.com/ByeongGil-Jun/examples-lingua-franca/blob/chat_char/C/src/ChatApplication/SimpleChatN_string.lf

In addition, the error doesn't occur when I change the input's type to integer or char pointer.

hokeun commented 2 years ago

To explain in more detail:

This error is raised at this line: https://github.com/ByeongGil-Jun/examples-lingua-franca/blob/chat_char/C/src/ChatApplication/SimpleChatN_string.lf#L100

Even if the type of receive and s.in is the same (both are string multiports).

We tried changing the types to int multiports and char* multiports. However, there was no error raised in these case.

So we concluded that this type mismatch error occurs only when the type is string multiports for the LHS and RHS of the connection.

Do we disallow the direct connection between string multiports specifically? Otherwise, I think this should be a bug.

hokeun commented 2 years ago

Please let us know if any more information is needed!

lhstrh commented 2 years ago

The target specified in this file is C, but C doesn't have a string data type... I agree that the error message could be more accurate, the error itself is legitimate.

edwardalee commented 2 years ago

The string datatype is defined by LF in the generated code, so it is legit to use it here. However, the type mismatch error no longer occurs in the master branch. It is instead replaced by a large number of other errors in the code. E.g., it has:

reactor Sender (
    N:string(2)
) {

A string cannot be initialized with an integer. It then has:

reactor ChatHandler (
    N:int(2)
) {
...
    s = new Sender(N=N);

It is initializing a string parameter with the value of an int parameter.

hokeun commented 2 years ago

@ByeongGil-Jun Could you check the errors pointed out by @edwardalee ? We can also talk about this together on Wednesday.

byeonggiljun commented 2 years ago

@hokeun Yes, I'll check that and notice to you.

byeonggiljun commented 2 years ago

@edwardalee I fixed the code at https://github.com/ByeongGil-Jun/examples-lingua-franca/blob/chat_char/C/src/ChatApplication/SimpleChatN_string.lf that it only raises a string type error. Could you compile and look at this code when you have time? Additionally, this type of error only occurs when using multiport. The error doesn't raise when sending just one string to another reactor by not using multiport.