Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/semantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2434,14 +2434,14 @@ class TypeChecker {
if (id.tag === Tag.VID) {
this.checkVid(id, env);
const type = this.getVariableType(ast.left.id, env);
if (type.type === 'module_instance') {

if (type.type === 'module_instance' || (type.type === 'basic' && isBasicType(type.name))) {
ast.left.type = 'instance_call';
this.visitInstanceCall(ast, env);
return;
}
}
}

throw new Error('un-implemented');
}

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/tmp_var_call/main.dara
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import OSS;

type @str = string;

init(){
var config = new OSS.Config{};
var oss = new OSS(config);
Expand All @@ -10,5 +12,6 @@ init(){
var en = {
a = "b"
}.keySet();
var vtmp = @str.split('.');
}

18 changes: 9 additions & 9 deletions test/semantic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7719,22 +7719,22 @@ init() {

it('use tmp variable method call shoule be ok', function(){
const ast = readAndParse('fixtures/tmp_var_call/main.dara');
let tStrAst = ast.moduleBody.nodes[0].initBody.stmts[3];
let tStrAst = ast.moduleBody.nodes[1].initBody.stmts[3];
expect(tStrAst.expr.left.id.elements[1].expr.left).to.be.eql({
'type': 'static_call',
'id': {
'tag': 2,
'loc': loc(7, 21, 7, 24),
'loc': loc(9, 21, 9, 24),
'lexeme': 'OSS',
'index': 41,
'index': 46,
'type': 'module'
},
'propertyPath': [
{
'tag': 2,
'loc': loc(7, 25, 7, 36),
'loc': loc(9, 25, 9, 36),
'lexeme': 'accessKeyId',
'index': 43
'index': 48
}
]
});
Expand All @@ -7743,9 +7743,9 @@ init() {
'type': 'instance_call',
'id': {
'tag': 2,
'loc': loc(7, 42, 7, 45),
'loc': loc(9, 42, 9, 45),
'lexeme': 'oss',
'index': 47,
'index': 52,
'type': 'variable',
'moduleType': {
'type': 'module',
Expand All @@ -7755,9 +7755,9 @@ init() {
'propertyPath': [
{
'tag': 2,
'loc': loc(7, 46, 7, 60),
'loc': loc(9, 46, 9, 60),
'lexeme': 'getAccessKeyId',
'index': 49
'index': 54
}
]
});
Expand Down