simon816 / Command-Block-Assembly

Compile high-level code into Minecraft commands
https://www.simon816.com/minecraft/assembler
MIT License
272 stars 29 forks source link

Possible bug in event handler compilation in CBL #19

Closed sarahmence closed 4 years ago

sarahmence commented 4 years ago

I am trying to learn CBL, and I am having trouble with the event handler example compiling properly. I'm using this example, copied from the CBL syntax reference and modified slightly:

include "Text"
include "Events"

[Event Events.placed_block: {event.item.item: "minecraft:stone"}]
void on_stone_placed() {
    Text t;
    t += "Stone block placed";
    t.send_to_all();
}

When I attempt to compile this with MCC, I get this error message:

Diagnostic:
Compiling function .cbl_init
Current basic block: BasicBlock(_internal/.cbl_init/entry)
    entry:

src/main.cbl:0:0: error: __init__() missing 2 required positional arguments: 'func_members' and 'func_properties'

If I rewrite my code as follows:

include "Text"
include "Events"

[Event Events.placed_block]
void on_stone_placed() {
    Text t;
    t += "Stone block placed";
    t.send_to_all();
}

Then it compiles with no errors.

What (if anything) am I doing wrong, and how do I fix it?

Thanks!

simon816 commented 4 years ago

Ah, it's a bug in the compiler. I've just pushed a fix, should work now if you pull the latest commit