Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

closures can't be assigned to local variables #152

@sternenseemann

Description

@sternenseemann

Taken from the README with fixed syntax:

closure rand_t() -> int;

fn secure_random() -> int {
    return 42;
}

fn main() {
    rand_t rand = secure_random;
}

Compiling fails:

[ERROR] incompatible types ::zztest::main::rand_t and ::zztest::main::secure_random
 --> /home/lukas/src/misc/zztest/src/main.zz:8:5
  |
8 |     rand_t rand = secure_random;␊
  |     ^-------------------------^
  |
  = this expression is unprovable over incompatible types

 --> /home/lukas/src/misc/zztest/src/main.zz:8:5
  |
8 |     rand_t rand = secure_random;␊
  |     ^-------------------------^
  |
  = rand := ::zztest::main::rand_t Uninitialized

 --> /home/lukas/src/misc/zztest/src/main.zz:3:1
  |
3 | fn secure_random() -> int {␊
  | ...
6 | fn main() -> int {␊
  | ^
  |
  = ::zztest::main::secure_random := ::zztest::main::secure_random Uninitialized

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions