Open grum-tez opened 1 year ago
thanks @grum-tez , indeed the typer should be able to infer the type of the [ ]
literal, which can be either list or map; because here the expected type is map. it is something we should be improving.
there is a workaround with make_map
builtin to force the type:
var owm: map<band, map<string, duration>> = [];
owm.put(this_band, make_map<string, duration>([(id, ownership_asset[id].time_held)]));
Not sure if this is a bug or I don't understand the syntax - but compare these two things:
This is valid and compiles:
But if I copy-paste the literal directly into the put method argument, it doesn't compile.
This doesn't compile and gives "No such method: 'put'" in the vs code problems readout