Skip to content

Commit

Permalink
Fix exception handler and scoped disposal issues
Browse files Browse the repository at this point in the history
Bugs fixed:
- Returning from finally doesn't work reliably (closes #1100)
- Scoped disposal within an exception handler generates incorrect IL (closes #1101)
  • Loading branch information
degory committed Mar 4, 2024
1 parent 53645d7 commit 682eb41
Show file tree
Hide file tree
Showing 43 changed files with 876 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"ghul.compiler": {
"version": "0.8.8",
"version": "0.8.9",
"commands": [
"ghul-compiler"
]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.8.9-alpha.2</Version>
<Version>0.8.10-alpha.10</Version>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>

Expand Down
23 changes: 23 additions & 0 deletions integration-tests/execution/let-use-3/.vscode/tasks.json
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
}
}
]
}
Empty file.
1 change: 1 addition & 0 deletions integration-tests/execution/let-use-3/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
6 changes: 6 additions & 0 deletions integration-tests/execution/let-use-3/ghul.json
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 integration-tests/execution/let-use-3/ghulflags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--dotnet
Empty file.
107 changes: 107 additions & 0 deletions integration-tests/execution/let-use-3/run.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

testing let use in try
Check created
Hello World!
finished let use inside try. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. finished let use in try
test_let_use_in_try done

testing let use inside catch clause
in catch have exception 'expected'
Check created
Hello World!
finished let use inside catch clause
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before
test_let_use_in_catch done

testing let use inside finally without throw
no exception
in finally
Check created
Hello World!
finished let use inside finally clause. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before.
test_let_use_in_finally_no_throw done

testing let use inside finally clause with throw
in finally
Check created
Hello World!
finished let use inside finally clause with throw. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
expected: caught exception

testing let use inside try in catch clause
in inner catch have exception 'Exception of type 'System.Exception' was thrown.'
Check created
Hello World!
finished let use inside try in catch clause. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. in outer finally
test_let_use_in_catch_inside_try done

testing let use inside catch in catch clause
in outer catch have exception 'outer expected'
in inner catch have exception 'inner expected'
Check created
Hello World!
finished let use inside catch in catch clause. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. in outer finally
test_let_use_in_catch_inside_catch done

testing let use inside catch in finally clause
in inner catch have exception 'inner expected'
Check created
Hello World!
finished let use inside catch in finally clause. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. in outer finally
expected: caught exception

testing return from catch with let use
Check created
Hello World!
finished let use inside catch. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. finished return from catch with let use
test_return_from_catch_with_let_use done

testing return from try with let use
Check created
Hello World!
finished let use inside try. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
<<< expect dispose before. finished return from try with let use
test_return_from_try_with_let_use done

testing return from finally with let use
no exception
Check created
Hello World!
finished let use inside finally in finally clause. expect dispose after
>>> expect dispose after
disposing Check...
disposed Check
done
Loading

0 comments on commit 682eb41

Please sign in to comment.