1#include <emscripten/val.h> 2 3using emscripten::val; 4 5int main() { 6 val obj = val::object(); 7 // Code like below doesn't work like the user might expect. 8 // `obj[...] = ...` only modifies the on-stack `val` binding, whereas user probably wanted to set the property on the actual JS object. 9 // The correct way to set the property is via `val::set()` instead, like `obj.set("foo", 42)`. 10 // Test here that we help catch this mistake and produce a compilation error for the line below. 11 obj["foo"] = val(42); 12} 13 14