Skip to content
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

搜集常见报错信息 #14

Open
nobodxbodon opened this issue Jul 1, 2021 · 1 comment
Open

搜集常见报错信息 #14

nobodxbodon opened this issue Jul 1, 2021 · 1 comment

Comments

@nobodxbodon
Copy link
Contributor

不知能搜集得多完全,但希望至少开个头。几种搜集方式:

  • 跑一些例程和教程,期间碰到的报错信息记录下来,添加解释与例程,比如 前文 中的报错、括号不匹配等等
  • 在 covscript 源码中搜索报错信息,并逐渐补上对应例程

有何建议吗?

@nobodxbodon
Copy link
Contributor Author

先逐个记录在此吧,回头再整理文档。使用了在线环境进行测试,>>>之前的为例程,之后的为返回信息。每个例程后有简要解释。

Use of undefined variable

想的 = 0
>>>
Runtime Error: Use of undefined variable "想的".

在变量(variable)未声明前引用此变量,就会报此错。初学者容易忘记在声明变量时需用 var 打头,正确的声明方法是:var 想的 = 0

function 平方(数)
  返回值 = 数*数
end
平方(2)
>>>
Runtime Error: Use of undefined variable "返回值".
>	返回值 = 数*数

类似的,函数定义内的局部变量未声明。改进可能:如果仅声明了函数而未调用,则运行不报错。可否在即使未调用时也报错?便于尽早发现问题。

var 想的 = randint(1,100)
>>>
Runtime Error: Use of undefined variable "randint".

虽然提示中的用词是“变量”,此处实际上是未找到函数。 改进可能:与标准、扩展库API作对比,如果有匹配(或疑似匹配),可以推荐API的正确调用方法

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

No branches or pull requests

1 participant