Maybe I am missing something obvious, but is it intentional that enable_indexscan is checked by cost_index(), that is, *after* creating an index path? I was expecting that if enable_indexscan is off, then no index paths would be generated to begin with, because I thought they are optional.
I think the cost estimate of index paths is the same as other paths on that setting enable_xxx to off only adds a penalty factor (disable_cost) to the path's cost. The path would be still generated and compete with other paths in add_path().