Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not decl shared Buffer!() bufchar ? #2

Closed
mw66 opened this issue Jun 12, 2020 · 2 comments
Closed

can not decl shared Buffer!() bufchar ? #2

mw66 opened this issue Jun 12, 2020 · 2 comments

Comments

@mw66
Copy link

mw66 commented Jun 12, 2020

$ cat cb.d

#!/usr/bin/env dub
/+ dub.sdl:
name "app"
dependency "elembuf" version="~>1.1.1"
+/

import buffer;

void main() {
        shared Buffer!() bufchar = Buffer!()();
        assert(bufchar == "");
}

compile error:

$ dub.exe cb.d
cb.d(10,19): Error: cannot implicitly convert expression opCall(((Buffer!(char, false) __tmpfordtor7 = opCall();) , __tmpfordtor7).buf) of type Buffer!(char, fal
se) to shared(Buffer!(char, false))
cb.d(10,19):        bufchar = opCall(((Buffer!(char, false) __tmpfordtor7 = opCall();) , __tmpfordtor7).buf) is the first assignment of bufchar therefore it repr
esents its initialization
cb.d(10,19):        opAssign methods are not used for initialization, but for subsequent assignments
cb.d(11,9): Error: array equality comparison type mismatch, shared(char[]) vs string
C:\project\dmd2\windows\bin64\dmd.exe failed with exit code 1.
@Cyroxin
Copy link
Owner

Cyroxin commented Jun 13, 2020

Heya!

There is no implicit conversion from mutable to shared, you will have to explicitly cast it. I assume that with arrays, they are made constant, then immutable and finally shared to be able to be implicit. I've been testing methods of implementing implicit conversion, but have yet to find any success.

Here is an example on how to make the buffer shared. I'll be adding some docs later on as well.
31a11ab

@mw66
Copy link
Author

mw66 commented Jun 14, 2020

ok, cast works.

@mw66 mw66 closed this as completed Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants