Files
mgmt/lang/interpret_test/TestAstFunc2/lookup4.txtar
James Shubin d46c43df5a lang: core: Let lookup function specialize earlier
If we happen to know some information, we can specialize early and help
type unification solve things.
2025-01-26 18:21:54 -05:00

23 lines
528 B
Plaintext

-- main.mcl --
# FIXME: We'd instead love to do this during type unification with a callback or
# similar, but at least for now we can handle some common cases.
$bigmap = {
"key1" => {
"foo" => "thing1a",
"bar" => "thing1b",
},
"key2" => {
"foo" => "hello", # pull out this!
"bar" => "thing2b",
},
}
$key = "key2"
#$inner map{str: str} = $bigmap[$key] # does unify with the type hint!
$inner = $bigmap[$key] # doesn't unify without special function code!
test [$inner["foo"],] {}
-- OUTPUT --
Vertex: test[hello]