This was fixed in 8.0 with commit afa24a, but not on 7.8. Is it okay to backport this fix? See branch rosuav/backport_program_indexing_fix which is cherry-picking that commit and fixing an insignificant merge conflict.
Test case:
constant foo="test"; int main() {write("%O\n",this_program["foo"]);}
On 7.8, this fails with "Indexing on illegal type".
ChrisA