SI-8045 type inference of extracted value

Test case for SI-8045, fixed by the preceding commits.