in lib/semantic.js [2561:2591]
getVariableType(id, env) {
if (id.tag === Tag.VID) {
const def = this.getInstanceProperty(id.lexeme);
return this.getType(def.value);
}
const name = id.lexeme;
if (env.local && env.local.hasDefined(name)) {
// 返回作用域链上定义的值
return env.local.get(name);
}
if (this.enums.has(name)) {
return _enum(name);
}
if (this.models.has(name)) {
return _basic('class');
}
if (this.dependencies.has(name)) {
return _basic('class');
}
if (isTmpVariable(id.type)) {
return this.getExprType(id, env);
}
console.log(id);
throw new Error('Can not get the type for variable');
}