rhaiscript / rhai

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

Unreachable code should panic? #340

Closed adautopaulazup closed 3 years ago

adautopaulazup commented 3 years ago

Hi Guys,

First of all, I wanna say thank you for the incredible work, Rhai is amazing.

Assume a script with the following syntax error:

let my_obj = #{
   "movie-names" : ["Matrix","Star Wars"]
};

my_obj["movie-names"].().to_string();

Running this will lead the application to panic...even the playground could not recover after executing such a script, you have to reload the page to run any other script there. So, my question is: Why no return an EvalAltResult instead?

schungx commented 3 years ago

Good catch. All panics are considered bugs. Rhai is designed to not bring down the host system.

schungx commented 3 years ago

A fix has been pushed to the latest master. Please pull from here to check if it is now ok. Thanks!

adautopaulazup commented 3 years ago

I ran a few tests here and it's fixed. Thanks!

schungx commented 3 years ago

Thanks for catching this bug!