-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better handling of incomplete function signatures (#1103)
Enhancements: - Improved error reporting and parser recovery for incomplete function signatures (see #1086)
- Loading branch information
Showing
192 changed files
with
1,866 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
] | ||
}, | ||
"ghul.compiler": { | ||
"version": "0.8.9", | ||
"version": "0.8.10", | ||
"commands": [ | ||
"ghul-compiler" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
#!/bin/bash | ||
for f in `find integration-tests -name failed`; do | ||
DIR=`dirname $f` | ||
|
||
if [ ! -f $DIR/disabled ] ; then | ||
code `dirname $f` ; read -n 1 -s | ||
FAILED="" | ||
|
||
for f in $(find integration-tests -name failed); do | ||
DIR=$(dirname "$f") | ||
|
||
if [ ! -f "$DIR/disabled" ]; then | ||
FAILED="$FAILED $DIR" | ||
fi | ||
done | ||
|
||
if [ -n "$FAILED" ]; then | ||
code $FAILED | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test.ghul: 4,18..4,26: error: explicit argument type required | ||
test.ghul: 5,5..5,7: error: syntax error: expected ) but found si |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ namespace Test.ParseUnary is | |
class Test is | ||
function(argument | ||
si | ||
si | ||
si |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test.ghul: 6,5..6,7: error: in type expression: expected ( or identifier but found si | ||
test.ghul: 6,5..6,7: error: syntax error: expected ) but found si |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Test.ParseUnary is | ||
namespace Test.IncompleteMethodSignature is | ||
use Collections; | ||
|
||
class Test is | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test.ghul: 3,28..3,30: error: in type expression: expected ( or identifier but found in | ||
test.ghul: 4,5..4,7: error: syntax error: expected ) but found si |
23 changes: 23 additions & 0 deletions
23
integration-tests/parse/incomplete-function-signature-1/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run test", | ||
"command": "dotnet ghul-test \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Capture test expectation", | ||
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-1/err.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.ghul: 11,16..11,17: error: syntax error: incomplete formal arguments |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-1/fail.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
integration-tests/parse/incomplete-function-signature-1/ghul.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compiler": "dotnet ../../../publish/ghul.dll", | ||
"source": [ | ||
"." | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-1/ghulflags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--type-check |
Empty file.
33 changes: 33 additions & 0 deletions
33
integration-tests/parse/incomplete-function-signature-1/test.ghul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use IO.Std.write_line; | ||
|
||
test_first(a: int) is | ||
write_line("test_first"); | ||
si | ||
|
||
test_before(b: string) is | ||
write_line("test_before"); | ||
si | ||
|
||
test_incomplete( | ||
|
||
test_after(c: int) is | ||
write_line("test_after"); | ||
si | ||
|
||
test_last() is | ||
write_line("test_last"); | ||
si | ||
|
||
entry() is | ||
test_first(1); | ||
test_before("a"); | ||
|
||
// test_incomplete() should be defined, | ||
// even though its argument list is incomplete | ||
// and it should have zero formal arguments: | ||
test_incomplete(); | ||
|
||
test_after(2); | ||
test_last(); | ||
si | ||
|
Empty file.
23 changes: 23 additions & 0 deletions
23
integration-tests/parse/incomplete-function-signature-10/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run test", | ||
"command": "dotnet ghul-test \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Capture test expectation", | ||
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-10/disabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-10/err.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.ghul: 6,15..6,16: error: syntax error: expected , but found identifier b |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-10/fail.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
integration-tests/parse/incomplete-function-signature-10/ghul.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compiler": "dotnet ../../../publish/ghul.dll", | ||
"source": [ | ||
"." | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-10/ghulflags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--type-check |
Empty file.
44 changes: 44 additions & 0 deletions
44
integration-tests/parse/incomplete-function-signature-10/test.ghul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use IO.Std.write_line; | ||
|
||
test_first(a: int) is | ||
write_line("test_first"); | ||
si | ||
|
||
test_before(b: string) is | ||
write_line("test_before"); | ||
si | ||
|
||
test_incomplete(a: int, b: int) -> Collections.LIST[ // FIXME: error cascade | ||
|
||
test_after(c: int) is | ||
write_line("test_after"); | ||
|
||
si | ||
|
||
test_last() is | ||
write_line("test_last"); | ||
si | ||
|
||
entry() is | ||
test_first(1); | ||
test_before("a"); | ||
|
||
// test_incomplete() should be definedd | ||
// it should have two arguments, both | ||
// of which are of type int | ||
test_incomplete(123, 456); | ||
|
||
test_incomplete("abc", "abc"); // expect error | ||
|
||
// ideally test_incomplete() would have a return type | ||
// of error (compatible with any type) but we | ||
// can't represent that as a type expression, only | ||
// as an actual type, so the error we get here is | ||
// not that helpful | ||
|
||
let a: int = test_incomplete(123, 456); // expect error | ||
|
||
test_after(2); | ||
test_last(); | ||
si | ||
|
Empty file.
23 changes: 23 additions & 0 deletions
23
integration-tests/parse/incomplete-function-signature-11/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run test", | ||
"command": "dotnet ghul-test \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Capture test expectation", | ||
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-11/err.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.ghul: 13,24..13,25: error: syntax error: incomplete formal arguments |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-11/fail.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
integration-tests/parse/incomplete-function-signature-11/ghul.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compiler": "dotnet ../../../publish/ghul.dll", | ||
"source": [ | ||
"." | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-11/ghulflags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--type-check |
Empty file.
36 changes: 36 additions & 0 deletions
36
integration-tests/parse/incomplete-function-signature-11/test.ghul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Test is | ||
use IO.Std.write_line; | ||
|
||
class TEST is | ||
test_first(a: int) is | ||
write_line("test_first"); | ||
si | ||
|
||
test_before(b: string) is | ||
write_line("test_before"); | ||
si | ||
|
||
test_incomplete( | ||
|
||
test_after(c: int) is | ||
write_line("test_after"); | ||
si | ||
|
||
test_last() is | ||
write_line("test_last"); | ||
si | ||
|
||
init() is | ||
test_first(1); | ||
test_before("a"); | ||
|
||
// test_incomplete() should be defined, | ||
// even though its argument list is incomplete | ||
// and it should have zero formal arguments: | ||
test_incomplete(); | ||
|
||
test_after(2); | ||
test_last(); | ||
si | ||
si | ||
si |
Empty file.
23 changes: 23 additions & 0 deletions
23
integration-tests/parse/incomplete-function-signature-12/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run test", | ||
"command": "dotnet ghul-test \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Capture test expectation", | ||
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
integration-tests/parse/incomplete-function-signature-12/err.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test.ghul: 13,25..13,26: error: syntax error: incomplete formal arguments | ||
test.ghul: 35,29..35,30: error: no overload found for test_incomplete() |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-12/fail.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
integration-tests/parse/incomplete-function-signature-12/ghul.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compiler": "dotnet ../../../publish/ghul.dll", | ||
"source": [ | ||
"." | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/parse/incomplete-function-signature-12/ghulflags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--type-check |
Empty file.
41 changes: 41 additions & 0 deletions
41
integration-tests/parse/incomplete-function-signature-12/test.ghul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace TestIncompleteMethodSignature12 is | ||
use IO.Std.write_line; | ||
|
||
class TEST is | ||
test_first(a: int) is | ||
write_line("test_first"); | ||
si | ||
|
||
test_before(b: string) is | ||
write_line("test_before"); | ||
si | ||
|
||
test_incomplete(a: | ||
|
||
test_after(c: int) is | ||
write_line("test_after"); | ||
|
||
si | ||
|
||
test_last() is | ||
write_line("test_last"); | ||
si | ||
|
||
entry() is | ||
test_first(1); | ||
test_before("a"); | ||
|
||
// test_incomplete() should be defined, | ||
// even though its argument list is incomplete | ||
// and it should have one formal argument | ||
// of error type (accepts any type of argument) | ||
test_incomplete(123); | ||
test_incomplete("abc"); | ||
|
||
test_incomplete(); // expect error | ||
|
||
test_after(2); | ||
test_last(); | ||
si | ||
si | ||
si |
Empty file.
Oops, something went wrong.