Giter VIP home page Giter VIP logo

Comments (7)

yuyi98 avatar yuyi98 commented on September 4, 2024 1

mut eb := new_event_bus[string]()
It's wrong to use it here.
We should use shared eb := new_event_bus[string]().

from v.

JalonSolov avatar JalonSolov commented on September 4, 2024

I cannot reproduce the problem on my Linux machine. How did you trigger it? When I run the program after compiling as shown, it just hangs until I hit Ctrl-C:

[jalon@7950x v]$ ./v -g -o vdbg cmd/v && ./vdbg event_bus_trial.v
[jalon@7950x v]$ ./event_bus_trial
^C
[jalon@7950x v]$

from v.

spytheman avatar spytheman commented on September 4, 2024

It is reproducible on macos:
0[15:17:22]@m1: (master) /opt/v $ v -cc clang run ee.v
signal 11: segmentation fault
0 libsystem_platform.dylib 0x00000001805af584 _sigtramp + 56
1 ee 0x00000001045542cc map_key_to_index + 36
2 ee 0x000000010453c3a4 map_exists + 32
3 ee 0x000000010457bdcc main__EventBus_T_string_subscribe_T_string + 112
4 ee 0x000000010457c070 main__main + 84
5 ee 0x000000010457c760 main + 84
6 dyld 0x00000001801f60e0 start + 2360
139[15:17:34]@m1: (master) /opt/v $

from v.

spytheman avatar spytheman commented on September 4, 2024

mut eb := new_event_bus[string]() It's wrong to use it here. We should use shared eb := new_event_bus[string]().

That is right.
I think we should add a checker error, for mut eb, used for methods with shared receivers.

struct Abc { x int }
fn f(shared a Abc) { lock a { println(a.x) } }
fn (shared a Abc) m(){ lock a { println(a.x) } }
// mut a := Abc{}
// f(a) // checker error

mut b := Abc{} // if b is not mutable, there is a checker error, telling the user to declare `b` with `mut` to make it mutable; the message can be changed too, to mention that it should be `shared` too
b.m() // no checker error, but it is better to have one, similar to the `f(a)` case above

from v.

yuyi98 avatar yuyi98 commented on September 4, 2024

Yes, we should add a checker error.

from v.

medvednikov avatar medvednikov commented on September 4, 2024

I've removed shared receivers from V. Passing tests, will be live soon.

from v.

medvednikov avatar medvednikov commented on September 4, 2024

(as discussed on discord)

from v.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.