Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This compiles and shouldn't. #700

Closed
eholk opened this issue Jul 15, 2011 · 2 comments
Closed

This compiles and shouldn't. #700

eholk opened this issue Jul 15, 2011 · 2 comments
Labels
A-type-system Area: Type system

Comments

@eholk
Copy link
Contributor

eholk commented Jul 15, 2011

fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
              ast::node_id id) -> result {
    auto bcx = cx;
    auto chn = trans_expr(bcx, lhs);
    bcx = chn.bcx;
    auto data = trans_lval(bcx, rhs);
    bcx = data.res.bcx;
    auto chan_ty = node_id_type(cx.fcx.lcx.ccx, id);
    auto unit_ty;
    alt (ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
        case (ty::ty_chan(?t)) { unit_ty = t; }
        case (_) { bcx.fcx.lcx.ccx.sess.bug("non-chan type in trans_send"); }
    }

    auto target = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.chan_target_task,
                                 ~[bcx.fcx.lltaskptr, llchanval]);

    auto data_tmp = deep_copy(bcx, data.res.val, unit_ty, target);

    bcx = data_tmp.bcx;
    auto llchanval = bcx.build.PointerCast(chn.val, T_opaque_chan_ptr());
    auto lldataptr = bcx.build.PointerCast(data_tmp.val, T_ptr(T_i8()));
    bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.send,
                   ~[bcx.fcx.lltaskptr, llchanval, lldataptr]);
    ret rslt(bcx, chn.val);
}

Sorry it's so long, it wasn't obvious how to reduce it. This is code copied out of trans_comm.rs, but with some as-yet uncommitted changes. It's causing an LLVM assert because I'm passing llchanval to Build in the auto target = ... line. I'm using llchanval before it's even declared, let along initialized.

@catamorphism
Copy link
Contributor

This is probably a dup of #481.

@eholk
Copy link
Contributor Author

eholk commented Jul 15, 2011

Partially. There's the design question of whether it's legal to refer to a variable before it's declared. In this example, however, llchanval was definitely not initialized when I first tried to read from it, which seems like it's a typestate error.

@ghost ghost assigned catamorphism Jul 15, 2011
pdietl pushed a commit to pdietl/rust that referenced this issue Apr 23, 2020
group signed and unsigned integers in layout table
bors pushed a commit to rust-lang-ci/rust that referenced this issue Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants