diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-30 15:46:56 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-30 15:46:56 -0300 |
commit | e073cbc2e538369e0611abfc9948f301aea6aef3 (patch) | |
tree | 6ef30a285092e8bcc15021b1d857a62dbab36fd6 /testes | |
parent | 2316ec4c24a475e091ec3153a5bd908801a3a109 (diff) | |
download | lua-e073cbc2e538369e0611abfc9948f301aea6aef3.tar.gz lua-e073cbc2e538369e0611abfc9948f301aea6aef3.tar.bz2 lua-e073cbc2e538369e0611abfc9948f301aea6aef3.zip |
Better error messages for invalid operands in numeric 'for'
"Better" and similar to error messages for invalid function arguments.
*old message: 'for' limit must be a number
*new message: bad 'for' limit (number expected, got table)
Diffstat (limited to 'testes')
-rw-r--r-- | testes/errors.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/testes/errors.lua b/testes/errors.lua index 142e8b33..74975e31 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -154,6 +154,16 @@ checkmessage("a = 24 // 0", "divide by zero") | |||
154 | checkmessage("a = 1 % 0", "'n%0'") | 154 | checkmessage("a = 1 % 0", "'n%0'") |
155 | 155 | ||
156 | 156 | ||
157 | -- numeric for loops | ||
158 | checkmessage("for i = {}, 10 do end", "table") | ||
159 | checkmessage("for i = io.stdin, 10 do end", "FILE") | ||
160 | checkmessage("for i = {}, 10 do end", "initial value") | ||
161 | checkmessage("for i = 1, 'x', 10 do end", "string") | ||
162 | checkmessage("for i = 1, {}, 10 do end", "limit") | ||
163 | checkmessage("for i = 1, {} do end", "limit") | ||
164 | checkmessage("for i = 1, 10, print do end", "step") | ||
165 | checkmessage("for i = 1, 10, print do end", "function") | ||
166 | |||
157 | -- passing light userdata instead of full userdata | 167 | -- passing light userdata instead of full userdata |
158 | _G.D = debug | 168 | _G.D = debug |
159 | checkmessage([[ | 169 | checkmessage([[ |