lower: diagnose passing a by-ref loop capture where a value is expected
`for xs: (*m)` binds `m` to a `*T`. Passing it directly to a parameter that wants `T` produced invalid IR that only LLVM's verifier caught, with the opaque 'Call parameter type does not match function signature'. Detect it at the call site and emit a clear error with a fix-it suggesting `m.*`. Add example 215 + expected output as a regression test.
This commit is contained in:
1
tests/expected/215-ref-capture-value-arg-diagnostic.exit
Normal file
1
tests/expected/215-ref-capture-value-arg-diagnostic.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
10
tests/expected/215-ref-capture-value-arg-diagnostic.txt
Normal file
10
tests/expected/215-ref-capture-value-arg-diagnostic.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
error: by-reference loop capture 'm' has type '*Move', but 'Move' is expected here
|
||||
--> /Users/agra/projects/sx/examples/215-ref-capture-value-arg-diagnostic.sx:15:14
|
||||
|
|
||||
15 | take(m);
|
||||
| ^
|
||||
|
||||
help: dereference it to pass the value: `m.*`
|
||||
|
|
||||
15 | m.*
|
||||
| ^
|
||||
Reference in New Issue
Block a user