-
-
Notifications
You must be signed in to change notification settings - Fork 657
const(Object)ref #3
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
Conversation
…as original behaviour).
Added a pull request for corresponding Phobos changes: |
Thanks for all the hard work you've done on this. I haven't been able to get to it yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these correct? They implicitly convert, unless I'm missing something.
const(Object) -> const(Object)ref
and
immutable(Object) -> const(Object) -> const(Object)ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, they implicitly convert if you assign from one variable to another, but if you want to pass the value by ref
it won't work.
It's not entirely clear to me either what should work and what shouldn't. The tests with pointers below do match in these two cases, but they also match the shared
variant which is obviously wrong. The language definition regarding templates isn't clear on that either, it was obviously written before const
was added. So what is a bug and what isn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's not clear to me either.
As far as I can tell template deduction should ignore ref parameters, and this should be handled at a higher level. Of course at the moment, it's barely handled at all for template functions with ifti.
Are any implicit conversions allowed to be passed to ref parameters? (ignoring current bugs)
I think it will be safe to allow T : U
to match for any implicit conversion once these bugs are fixed (and do ref parameter matching as something like T* : U*
)
I agree the shared conversion is completely wrong. I think it's related to bug 5493, as the recursive deduction of types does not keep track of how many indirections deep it is, moving through something like:
shared(int)* : const(int)*
shared(int) : const(int)
which implicitly converts.
Conflicts: src/expression.c src/osx.mak
This pull request is no longer being maintained and cannot be merged without more work being done to it. I'm not going to do that work at this point, so I'm closing it. |
Add std.string.outdent (try dlang#3)
Trivial: switch to Ddoc module comment #3
Add tests for dll
Initializing the GC doesn't require busy state anymore.
# This is the 1st commit message: refactoring # This is the commit message #2: refactoring # This is the commit message #3: refactoring # This is the commit message #4: refactoring # This is the commit message #5: refactoring # This is the commit message #6: refactoring # This is the commit message #7: refactoring # This is the commit message #8: refactor/irstate-attrs refactoring add pragma(inline, true) change pragma(inline, true) -> pragma(inline, false) introduce root.Array.only and test it out in expressionsem (dlang#21520) [attrib.d] remove unused semantic import [dstruct.d] remove unused import [aggregate.d] move `searchCtor` to `expressionsem.d` remove some now unused semantic symbols from the import list. [cond.d] remove unused `typesem` import (dlang#21538) [expression.d] restrict `typesem` import fix dlang#19587 No debug line info for simple code blocks (dlang#21544) set location info on return statement, not only on return expression [dsymbol.d] remove dependance on glue layer (dlang#21532) move `loadModuleFromLibrary` to `dsymbolsem.d` (dlang#21535) remove `dmodule.d` dependance of a few more `dsymbolsem.d` symbols. [func.d] remove dependance on glue layer (dlang#21534) [aggregate.d] move `checkOverlappedFields` to `dsymbolsem.d` (dlang#21542) and make private Templatize `_adEq2` (dlang#21513) * Mark array literals as `on-stack` to bypass `@nogc` analysis * Update `fail_compilation` test output After updating the memcmp-ability criteria, now dynamic array can also be compared using `memcmp` if their element type is comparable bit by bit. refactor: use new array constructor throughout expressionsem refactoring refactoring refactoring refactoring refactoring refactoring refactoring refactoring refactoring
Limit the number of platforms that this is done on. A inspection of some libc implementations of fork has identified the main culprits, don't need to apply this to any others. MacOS testsuite also regressed as a result on calling this code, it's not clear why, but the backtrace is: ``` * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) * frame #0: 0x00007ff81abe6ee3 libsystem_platform.dylib`_os_unfair_lock_recursive_abort + 23 frame #1: 0x00007ff81abe12da libsystem_platform.dylib`_os_unfair_lock_lock_slow + 247 frame #2: 0x00007ff81abccd44 libsystem_pthread.dylib`_pthread_atfork_prepare_handlers + 48 frame dlang#3: 0x00007ff825dc2705 libSystem.B.dylib`libSystem_atfork_prepare + 25 frame dlang#4: 0x00007ff81aac17e1 libsystem_c.dylib`fork + 24 frame dlang#5: 0x0000000101f730ee test_runner`core.internal.backtrace.dwarf.resolveAddressesWithAtos(Location[]) + 210 ```
Limit the number of platforms that this is done on. A inspection of some libc implementations of fork has identified the main culprits, don't need to apply this to any others. MacOS testsuite also regressed as a result on calling this code, it's not clear why, but the backtrace is: ``` * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) * frame #0: 0x00007ff81abe6ee3 libsystem_platform.dylib`_os_unfair_lock_recursive_abort + 23 frame #1: 0x00007ff81abe12da libsystem_platform.dylib`_os_unfair_lock_lock_slow + 247 frame #2: 0x00007ff81abccd44 libsystem_pthread.dylib`_pthread_atfork_prepare_handlers + 48 frame #3: 0x00007ff825dc2705 libSystem.B.dylib`libSystem_atfork_prepare + 25 frame #4: 0x00007ff81aac17e1 libsystem_c.dylib`fork + 24 frame #5: 0x0000000101f730ee test_runner`core.internal.backtrace.dwarf.resolveAddressesWithAtos(Location[]) + 210 ```
This branch implements the
const(Object)ref
syntax as proposed in bug 5325. It also add many tests including type deduction. It also successfully compile druntime and Phobos. Phobos needs a very minor patch for theRebindable
unittest to pass, see branch const-object-ref in my Phobos repository.How it works at a glance:
head()
member which returns a pointer to a type representing their head. Non-class types have no distinct head modifiers, so theirhead()
is just a pointer to themselves. For classes,head()
returns aClassRefSuffix
type with the proper modifiers for the head, except when the head modifiers are the same as the class itself in which case the class type itself is returned.mutableOf()
now return a class type where only the head modifier was made mutable. If you want a mutable reference to an immutable class, you just doclassType->immutbleOf()->mutableOf()
--immutableOf
will make both the reference and the class immutable (because of transitivity), andmutableOf
will then make only the head mutable.head()->mod
.Of note:
inout
tests are commented out becauseinout
doesn't work well yet for non-class parameters, and fixing inout is beyond the scope of this patch.