Skip to content

Faults and compile time directives propagation #2338

@hamkoroke

Description

@hamkoroke

Found the following situation:

<*                                                          
 Description....       
 ...                                                            
 @return? mem::OUT_OF_MEMORY, RANGE_OVERFLOW, UNKNOWN_ERROR, ...
*>
fn SomeType? my_function(...)
{
    ...
}

Then in another module:

<*                                                          
 Description....       
 ...                                                            
 @return? mem::OUT_OF_MEMORY,... <---- do I need to repeat the same list here and maybe even have to add more faults from other call?
*>
fn void? other_function(...)
{
    my_function(...)!;
}

I'm not sure if other_function() inheriting the faults from my_function() automatically makes sense.
If we could do something like:

<*                                                          
 Description....       
 ...                                                            
 @return? my_function::faultdefs, OTHER_FAULT
*>
fn void? other_function(...)
{
    my_function(...)!;
}

Another situation I found where propagation was expected is when assigning conditional compilation directives (I was initially wondering if the conditions will propagate to callers):

fn Fd File.fd(self) @if(env::LIBC) {...}

wouldn't be good if we could only annotate File.fd as having this condition and then callers will inherit the annotation? So the callers of File.fd will be made available only on LIBC environments automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions