c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
3.02k stars 183 forks source link

Error quality: function parameter list does not flag an unknown type #1623

Open joshring opened 2 weeks ago

joshring commented 2 weeks ago
import std::time;

def Picoev_loop_id_t = ushort;

struct Picoev_loop {
    // read only
    Picoev_loop_id_t    loop_id;
    struct timeout {
        short*          vec;
        short*          vec_of_vec;
        usz             base_idx;
        time::Time      base_time;
        int             resolution;
        void*           _free_addr;
    }
    time::Time          now;
}

fn void picoev_set_timeout(
    picoev_loop* loop, // incorrect code
    // Picoev_loop* loop,  // correct code
    int fd, 
    int secs,
) @inline 
{
 return;
}

I expected it to determine picoev_loop was not a valid type, but I got this error instead:

Error: Expected ')'.

lerno commented 2 weeks ago

That one is hard. picoev_loop will be understood to be a macro parameter name, so it could only be followed by =, , or )

joshring commented 2 weeks ago

Q: would a macro parameter be unexpected in a function parameter list? could that be an error itself?

lerno commented 2 weeks ago

It's usually resolved in semantic checking.

lerno commented 1 week ago

So essentially I don't know if there is a great way to resolve this.