avoid the case that "hasAmbient" use before assign