Fix when( scalar ... ) bug