Currently, trying to access a key from a Const dict throws a semantic error stating type mismatch. An ASR pass error is thrown when trying to access values from a Const list. This was chiefly because the case of a Const value was not addressed in handling subscript indices. The error exists for Const types in general and will be addressed in subsequent commits.
Fix
This PR checks for Const when visiting subscript indices and handles access through the contained type.
Prerequisite
This PR depends on accessing the expr_t of the contained type inside Const. I have tried high and low but could not work out a fix. The variable in question is ASR::expr_t* value which is passed to visit_SubscriptIndices.
Overview
Currently, trying to access a key from a
Const dict
throws asemantic error
stating type mismatch. AnASR pass error
is thrown when trying to access values from aConst list
. This was chiefly because the case of aConst
value was not addressed in handling subscript indices. The error exists forConst
types in general and will be addressed in subsequent commits.Fix
This PR checks for
Const
when visiting subscript indices and handles access through the contained type.Prerequisite
This PR depends on accessing the
expr_t
of the contained type insideConst
. I have tried high and low but could not work out a fix. The variable in question isASR::expr_t* value
which is passed tovisit_SubscriptIndices
.The issue is:
Const[dict[str, i32]] = {"a": 1, "b": 2}
.value
containsConst[dict[str, i32]]
.We need
value
to get to storedict[str, i32]
.