avoid the case that "hasAmbient" use before assign
Merge pull request #170 from tangziwen/v3

avoid the case that "hasAmbient" use before assign