Skip to content

shares not working #4

@MohamedGhardallou

Description

@MohamedGhardallou

Describe the bug
Hello,
when trying to use individual array elements as function outputs

module exposes do_something

function calc_speed()(x : float32 , y : float32)
x = 5
y = 3
end

activity do_something()()
 var V : [2] float32 = { 0, 0 }
 calc_speed()(V[0], V[1] )
 await true
end

I got this error :
error: Write-write conflict. V or an alias thereof occurs multiple times in the output list of the sub program call.
--> prog.blc:13:2 [causality]

13 | calc_speed()(V[0], V[1] )
| ---- First occurence of output argument.
13 | calc_speed()(V[0], V[1] )
| ^^^^ Subsequent alias of the same output argument.

If this usage is intended, consider using the "shares" keyword when declaring the formal parameters of the subprogram.

Expected behaviour
It's clear that this program is safe. in case of runtime indexes it's very difficult for the compiler to verify the safety. in this case the programmer should have a mechanism to disable safety checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions