How to "dispose of" a string when using @live analysis?
Renato Athaydes
renato at athaydes.com
Fri Aug 29 17:13:21 UTC 2025
The following code fails to compile when using
[OB](https://dlang.org/spec/ob.html):
```d
@live void show(scope ref string s) {
import std.stdio;
writeln(s);
}
@live void main()
{
auto s = "foo bar";
show(s);
show(s);
}
```
Compile with:
```
dmd -preview=dip1021 ...
```
Error:
```
source/app.d(8): Error: variable `app.main.s` is not disposed of
before return
auto s = "foo bar";
^
```
How do I dispose of the string?
More information about the Digitalmars-d-learn
mailing list