You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code is a simplification of a conceptual error I've seen in student code when learning multiple dispatch:
function foo with bar do
with baz do 0
end
Awkwardly, asteroid reports "error: list index out of range" on the second line of the function. This is not particularly informative as there are no lists in the asteroid code.
Turning on Python exceptions with -e shows that this actually came from:
.../asteroid/walk.py, line 1994, in check_redundancy
first_line_h = LINE_LIST[0]
Turning off the redundant pattern detector with -r lets the function work with the empty statement list (in Asteroid 2.0.2), returning none. Here's a more useful variation on the theme:
load system io.
function foo with 0 do
with 1 do "not none"
end
io@println(tostring(foo(0))).
io@println(tostring(foo(1))).
(With the -r flag, prints none and not none.)
So, it does seem to be a legal program, just one which confuses the pattern redundancy detector, and that error confuses students.
I haven't looked enough at the codebase to know how difficult it would be to issue a warning if a program's AST includes an empty statement list, but that could be helpful.
The text was updated successfully, but these errors were encountered:
The following code is a simplification of a conceptual error I've seen in student code when learning multiple dispatch:
Awkwardly, asteroid reports "error: list index out of range" on the second line of the function. This is not particularly informative as there are no lists in the asteroid code.
Turning on Python exceptions with -e shows that this actually came from:
Turning off the redundant pattern detector with -r lets the function work with the empty statement list (in Asteroid 2.0.2), returning none. Here's a more useful variation on the theme:
(With the -r flag, prints
none
andnot none
.)So, it does seem to be a legal program, just one which confuses the pattern redundancy detector, and that error confuses students.
I haven't looked enough at the codebase to know how difficult it would be to issue a warning if a program's AST includes an empty statement list, but that could be helpful.
The text was updated successfully, but these errors were encountered: