Skip to content

Ar/typecheckfix #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 44 commits into from
Closed

Conversation

ArtistArthur
Copy link
Contributor

  • 增加了string.match的返回值类型
  • m.searchInfers临时增加了一个返回值以标识是否是class并且也是table,这是临时的,之后可以回退
  • 过了typecheck的测试

@sumneko
Copy link
Collaborator

sumneko commented Sep 29, 2021

我觉得可以明确一下规则:
凡是定义在 builtin 里的类型都是基础类型,基础类型不可被继承
凡是自定义的class都是table
这样应该不需要修改 m.searchInfers 了。

上面这个规则我晚点改一下试试

sumneko added a commit that referenced this pull request Sep 29, 2021
@ArtistArthur
Copy link
Contributor Author

自定义的类型都是table,那如果是alias呢,如果我用m.searchInfers,返回的只是名字,我可以看这里面有没有基本类型之外的类型,从而看是不是table,但是我并不知道这个之外的类型是alias还是类,并且有可能这个alias是table也可能不是table

@sumneko
Copy link
Collaborator

sumneko commented Sep 30, 2021

vm.getDocDefines

@ArtistArthur
Copy link
Contributor Author

好的,我大概解决了这个问题。有一个新的问题,之前也提过。
就是infer.searchinfers得到的类型,是全局的,与当前位置可能无关,比如
image
在当前报错位置,symbol.uri并不是nil,但是由于下面把他赋值为nil了,导致推断出来它的类型只有nil,虽然可能可以通过给它除了nil之外的类型来避免这个case,但是我还是想要一个功能:可以推断出来的类型是和当前位置相关的,比如以上的这个例子,在当前的位置不会被推断成nil,只有在赋值之后才会被推断成nil

@ArtistArthur
Copy link
Contributor Author

另外我发现一个问题
image
zhe'lian这两种调用传入的参数数量是不一样的,不加括号的话,我拿到的args只有一个,没有默认把self传进去,如果加了括号,则有self,这会导致typecheck的时候参数错位或者缺失
image

@sumneko
Copy link
Collaborator

sumneko commented Sep 30, 2021

好的,我大概解决了这个问题。有一个新的问题,之前也提过。 就是infer.searchinfers得到的类型,是全局的,与当前位置可能无关,比如 image 在当前报错位置,symbol.uri并不是nil,但是由于下面把他赋值为nil了,导致推断出来它的类型只有nil,虽然可能可以通过给它除了nil之外的类型来避免这个case,但是我还是想要一个功能:可以推断出来的类型是和当前位置相关的,比如以上的这个例子,在当前的位置不会被推断成nil,只有在赋值之后才会被推断成nil

这个要以后支持类型收窄才能实现

@sumneko
Copy link
Collaborator

sumneko commented Sep 30, 2021

另外我发现一个问题 image zhe'lian这两种调用传入的参数数量是不一样的,不加括号的话,我拿到的args只有一个,没有默认把self传进去,如果加了括号,则有self,这会导致typecheck的时候参数错位或者缺失 image

这个可能是BUG,我等会儿看一下

@ArtistArthur
Copy link
Contributor Author

好的。
现在我把infer的改动回退了,给guide.object加了个optional的域(因为我看到有这个域并且如果不加会warning)

if not typeName then
return false
elseif typeNameMap[typeName]
or infer.isInnerType(typeName) then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isInnerType 被我删掉了,因为我发现已经在 define.lua 里实现过了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
这个Function是对的吗?大写?我可以加个小写的吗?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来是写错了,我改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在改用 vm.isBuiltinType 来判断

sumneko added a commit that referenced this pull request Sep 30, 2021
@ArtistArthur
Copy link
Contributor Author

ArtistArthur commented Sep 30, 2021

又更新了下。
另外有一些奇怪的错误,明明不是nil却会被infer成nil,估计是searchInfers的一些问题:
image
image
这个nameCollect会被推断成nil
另外这个desc也会被推断成nil,是因为这个函数的返回值有一个是nil,但是感觉有点不太合理
image
这个地方的error第二个参数必须是数字吗?如果是的话这个地方obj.type是string吧,是可以的吗?
image

@ArtistArthur
Copy link
Contributor Author

请问我这个pr可以合吗?不知道为什么我今天合了master之后重新push上来,这个pr把很多并不是我的改动给diff出来了。
我本地看了下,大多数错误都修复了,还有几个少数的问题,我觉得应该可以先合一下?不过默认还是要忽略diag

@sumneko
Copy link
Collaborator

sumneko commented Oct 8, 2021

不可以把master合到你自己的分支里的
建议你在最新的master上重新建个分支,然后把你自己的提交都遴选过去,重新PR

@ArtistArthur
Copy link
Contributor Author

好的。
不过为什么不能合master呢?(我之前用的gitlab,一般如果master有改动了我就merge master,这是不好的操作吗?

@sumneko
Copy link
Collaborator

sumneko commented Oct 8, 2021

merge操作其实是丢弃掉另一侧的提交,然后由你来重新提交一遍。之后在PR的时候就会像现在这样出现别人的提交。
如果想要引入最新的master,应该使用 git rebase master

@ArtistArthur
Copy link
Contributor Author

哦哦好的

@sumneko sumneko closed this Oct 8, 2021
@ArtistArthur
Copy link
Contributor Author

另外我发现一个问题 image zhe'lian这两种调用传入的参数数量是不一样的,不加括号的话,我拿到的args只有一个,没有默认把self传进去,如果加了括号,则有self,这会导致typecheck的时候参数错位或者缺失 image

这个可能是BUG,我等会儿看一下

您好,这个bug您还没有修复好像

@sumneko sumneko mentioned this pull request Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants