rhaiscript / rhai

Rhai - An embedded scripting language for Rust.
https://crates.io/crates/rhai
Apache License 2.0
3.77k stars 178 forks source link

Fix compile error with no 'metadata' feature #815

Closed h7kanna closed 8 months ago

h7kanna commented 8 months ago

Fixed compile error as 'set_custom_type_with_comments' is gated with 'metadata' feature.

schungx commented 8 months ago

If metadata is not used, then comments is an empty array, so the branch with set_custom_type_with_comments is never called. I don't particularly see a bug here...

h7kanna commented 8 months ago

Below issue with

rhai = { version = "1.16.3", features = ["internals", "no_closure", "no_module", "no_custom_syntax"], optional = true }
Screenshot 2024-01-16 at 8 50 04 PM
schungx commented 8 months ago

What version of rhai_codegen are you using? Can you do a cargo update?

h7kanna commented 8 months ago

I am not using rhai_codegen directly. Now I realize that the usage of 'rhai' alone compiles just fine. May be, This is just IntelliJ IDE messing up with features.

schungx commented 8 months ago

I am not using rhai_codegen directly. Now I realize that the usage of 'rhai' alone compiles just fine. May be, This is just IntelliJ IDE messing up with features.

rhai will call rhai_codegen which is why you need to be careful about version conflicts. I suspect you have a lower version of rhai_codegen in your Cargo.lock...

Also, if the IDE is working on an old version of rhai_codegen that may also cause this problem...

h7kanna commented 8 months ago

But still, for the code to work set_fn_with_comments will not be in scope without 'metadata' feature. no?

schungx commented 8 months ago

But still, for the code to work set_fn_with_comments will not be in scope without 'metadata' feature. no?

Not, the codegen won't generate this function call without the metadata feature.

h7kanna commented 8 months ago

Cargo.lock

[[package]]
name = "rhai_codegen"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f"
dependencies = [
 "proc-macro2",
 "quote",
 "syn 2.0.48",
]
h7kanna commented 8 months ago

But still, for the code to work set_fn_with_comments will not be in scope without 'metadata' feature. no?

Not, the codegen won't generate this function call without the metadata feature.

Then its IDE not setting features correctly

h7kanna commented 8 months ago

This is just IntelliJ dealing badly with feature unification. Closing this.