forked from carp-lang/Carp
-
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.
test: add tests for lambda leak cases
Adds tests to ensure lambdas do not leak ownership of their captured variables. In addition, the nested lambda test now needs to accept a reference to a function instead of a function value (otherwise an ownership leak occurs).
- Loading branch information
Showing
3 changed files
with
12 additions
and
3 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
2 changes: 2 additions & 0 deletions
2
test/output/test/test-for-errors/lambda_leaking_capture_ownership.carp.output.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 @@ | ||
lambda_leaking_capture_ownership.carp:4:2 [ERROR] `I expected an array of valid arguments, but got: (let [string (copy "") leaks (fn [] s)]) | ||
- `defn` requires an array of arugments, but it got: (let [string (copy "") leaks (fn [] s)]) |
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,7 @@ | ||
(Project.config "file-path-print-length" "short") | ||
|
||
;; see [issue #1040](https://github.com/carp-lang/Carp/issues/1040) | ||
(defn lambda-leak | ||
(let [string @"" | ||
leaks (fn [] s)]) ;; disallow this | ||
()) |