diff options
Diffstat (limited to 'libphobos')
40 files changed, 271 insertions, 200 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 77e8562..d458bea 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -07bc5b9b3c81cc0d4314e0040de981124b363ea5 +66b93fc24a7ab5e2a8aa7f53c613df4abddc188b The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/libphobos/libdruntime/core/checkedint.d b/libphobos/libdruntime/core/checkedint.d index 49a5c11..4c40b99 100644 --- a/libphobos/libdruntime/core/checkedint.d +++ b/libphobos/libdruntime/core/checkedint.d @@ -186,8 +186,8 @@ unittest { bool overflow; immutable uint r = addu (uint.max - i, uint.max - i, overflow); - assert (r == 2 * (uint.max - i)); - assert (overflow); + assert(r == 2 * (uint.max - i)); + assert(overflow); } bool overflow; diff --git a/libphobos/libdruntime/core/internal/newaa.d b/libphobos/libdruntime/core/internal/newaa.d index 2fd9365..7c858f3 100644 --- a/libphobos/libdruntime/core/internal/newaa.d +++ b/libphobos/libdruntime/core/internal/newaa.d @@ -102,7 +102,7 @@ AAShell makeAA(K, V)(V[K] src) @trusted dim = dim * GROW_FAC; // used during runtime. - size_t delegate(scope const void *) nothrow hashFn = (scope const void* val) { + typeof(Impl.hashFn) hashFn = (scope const void* val) { auto x = cast(K*)val; return hashOf(*x); }; diff --git a/libphobos/libdruntime/core/internal/parseoptions.d b/libphobos/libdruntime/core/internal/parseoptions.d index 2bf1da2..2dd3ec8 100644 --- a/libphobos/libdruntime/core/internal/parseoptions.d +++ b/libphobos/libdruntime/core/internal/parseoptions.d @@ -219,13 +219,12 @@ do return overflowedError(optname, str); i++; - break; } else // unexpected non-digit character { i = 0; - break; } + break; } } diff --git a/libphobos/libdruntime/core/internal/traits.d b/libphobos/libdruntime/core/internal/traits.d index 0b2eb1f..f0d9ebc 100644 --- a/libphobos/libdruntime/core/internal/traits.d +++ b/libphobos/libdruntime/core/internal/traits.d @@ -51,7 +51,7 @@ unittest static assert(is(BaseElemOf!(int[1][2]) == int)); static assert(is(BaseElemOf!(int[1][]) == int[1][])); static assert(is(BaseElemOf!(int[][1]) == int[])); - static enum E : int[2]{ test = [0, 1] } + enum E : int[2]{ test = [0, 1] } static assert(is(BaseElemOf!(E) == int)); } @@ -809,30 +809,23 @@ unittest template hasUDA(alias symbol, alias attribute) { - alias attrs = __traits(getAttributes, symbol); + enum isAttr(T) = is(T == attribute); - static foreach (a; attrs) - { - static if (is(a == attribute)) - { - enum hasUDA = true; - } - } - - static if (!__traits(compiles, (hasUDA == true))) - enum hasUDA = false; + enum hasUDA = anySatisfy!(isAttr, __traits(getAttributes, symbol)); } unittest { - struct SomeUDA{} + enum SomeUDA; struct Test { int woUDA; - @SomeUDA int withUDA; + @SomeUDA int oneUDA; + @SomeUDA @SomeUDA int twoUDAs; } - static assert(hasUDA!(Test.withUDA, SomeUDA)); + static assert(hasUDA!(Test.oneUDA, SomeUDA)); + static assert(hasUDA!(Test.twoUDAs, SomeUDA)); static assert(!hasUDA!(Test.woUDA, SomeUDA)); } diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d index 9e563ad..f3dab36 100644 --- a/libphobos/libdruntime/core/lifetime.d +++ b/libphobos/libdruntime/core/lifetime.d @@ -104,7 +104,7 @@ T emplace(T, Args...)(T chunk, auto ref Args args) // Initialize the object in its pre-ctor state const initializer = __traits(initSymbol, T); - (() @trusted { (cast(void*) chunk)[0 .. initializer.length] = initializer[]; })(); + () @trusted { (cast(void*) chunk)[0 .. initializer.length] = cast(void[]) initializer[]; }(); static if (isInnerClass!T) { @@ -2683,7 +2683,7 @@ T _d_newThrowable(T)() @trusted debug(PRINTF) printf(" p = %p\n", p); // initialize it - p[0 .. init.length] = init[]; + p[0 .. init.length] = cast(void[]) init[]; import core.internal.traits : hasIndirections; if (hasIndirections!T) @@ -2776,7 +2776,7 @@ if (is(T == class)) } // initialize it - p[0 .. init.length] = init[]; + p[0 .. init.length] = cast(void[]) init[]; debug(PRINTF) printf("initialization done\n"); return cast(T) p; diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d index 4ff728c..1828861 100644 --- a/libphobos/libdruntime/core/runtime.d +++ b/libphobos/libdruntime/core/runtime.d @@ -613,7 +613,7 @@ extern (C) UnitTestResult runModuleUnitTests() static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr ) nothrow { - static enum MAXFRAMES = 128; + enum MAXFRAMES = 128; void*[MAXFRAMES] callstack; auto numframes = backtrace( callstack.ptr, MAXFRAMES ); @@ -942,7 +942,7 @@ else static if (hasExecinfo) private class DefaultTraceInfo : Throwable.TraceInf private: int numframes; - static enum MAXFRAMES = 128; + enum MAXFRAMES = 128; void*[MAXFRAMES] callstack = void; private: diff --git a/libphobos/libdruntime/core/stdcpp/allocator.d b/libphobos/libdruntime/core/stdcpp/allocator.d index abf97c4..a574cd3 100644 --- a/libphobos/libdruntime/core/stdcpp/allocator.d +++ b/libphobos/libdruntime/core/stdcpp/allocator.d @@ -147,7 +147,7 @@ extern(D): /// enum size_t max_size = size_t.max / T.sizeof; } - else version (CppRuntime_Gcc) + else version (CppRuntime_GNU) { /// T* allocate(size_t count, const(void)* = null) @nogc @@ -174,7 +174,7 @@ extern(D): /// enum size_t max_size = (ptrdiff_t.max < size_t.max ? cast(size_t)ptrdiff_t.max : size_t.max) / T.sizeof; } - else version (CppRuntime_Clang) + else version (CppRuntime_LLVM) { /// T* allocate(size_t count, const(void)* = null) @nogc @@ -360,7 +360,7 @@ version (CppRuntime_Microsoft) } } } -version (CppRuntime_Clang) +version (CppRuntime_LLVM) { // Helper for container swap package(core.stdcpp) void __swap_allocator(Alloc)(ref Alloc __a1, ref Alloc __a2) diff --git a/libphobos/libdruntime/core/stdcpp/array.d b/libphobos/libdruntime/core/stdcpp/array.d index 4cb0c56..912587c 100644 --- a/libphobos/libdruntime/core/stdcpp/array.d +++ b/libphobos/libdruntime/core/stdcpp/array.d @@ -74,7 +74,7 @@ pure nothrow @nogc: private: T[N ? N : 1] _Elems; } - else version (CppRuntime_Gcc) + else version (CppRuntime_GNU) { /// inout(T)* data() inout @safe { static if (N > 0) { return &_M_elems[0]; } else { return null; } } @@ -94,7 +94,7 @@ pure nothrow @nogc: _Placeholder _M_placeholder; } } - else version (CppRuntime_Clang) + else version (CppRuntime_LLVM) { /// inout(T)* data() inout @trusted { static if (N > 0) { return &__elems_[0]; } else { return cast(inout(T)*)__elems_.ptr; } } diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d index 4774b98..bd3be09 100644 --- a/libphobos/libdruntime/core/stdcpp/exception.d +++ b/libphobos/libdruntime/core/stdcpp/exception.d @@ -15,9 +15,9 @@ module core.stdcpp.exception; import core.stdcpp.xutility : __cplusplus, CppStdRevision; import core.attribute : weak; -version (CppRuntime_Gcc) +version (CppRuntime_GNU) version = GenericBaseException; -version (CppRuntime_Clang) +version (CppRuntime_LLVM) version = GenericBaseException; version (CppRuntime_Sun) version = GenericBaseException; diff --git a/libphobos/libdruntime/core/stdcpp/memory.d b/libphobos/libdruntime/core/stdcpp/memory.d index bd7976c..d7b6f17 100644 --- a/libphobos/libdruntime/core/stdcpp/memory.d +++ b/libphobos/libdruntime/core/stdcpp/memory.d @@ -123,7 +123,7 @@ nothrow pure @safe @nogc: _Compressed_pair!(Deleter, pointer) _Mypair; } - else version (CppRuntime_Gcc) + else version (CppRuntime_GNU) { /// ref inout(deleter_type) get_deleter() inout nothrow { return _M_t.get!1; } @@ -136,7 +136,7 @@ nothrow pure @safe @nogc: tuple!(pointer, Deleter) _M_t; } - else version (CppRuntime_Clang) + else version (CppRuntime_LLVM) { /// ref inout(deleter_type) get_deleter() inout nothrow { return __ptr_.second; } diff --git a/libphobos/libdruntime/core/stdcpp/string.d b/libphobos/libdruntime/core/stdcpp/string.d index 722b82f..0315867 100644 --- a/libphobos/libdruntime/core/stdcpp/string.d +++ b/libphobos/libdruntime/core/stdcpp/string.d @@ -31,7 +31,7 @@ version (Darwin) version = _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT; } -version (CppRuntime_Gcc) +version (CppRuntime_GNU) { version (_GLIBCXX_USE_CXX98_ABI) { @@ -894,7 +894,7 @@ extern(D): _String_alloc!(_String_base_types!(T, Alloc)) _Base; } - else version (CppRuntime_Gcc) + else version (CppRuntime_GNU) { version (_GLIBCXX_USE_CXX98_ABI) { @@ -1873,10 +1873,10 @@ extern(D): __d[0 .. __n] = __s[0 .. __n]; } } - else version (CppRuntime_Clang) + else version (CppRuntime_LLVM) { //---------------------------------------------------------------------------------- - // Clang/libc++ implementation + // libc++ implementation //---------------------------------------------------------------------------------- /// diff --git a/libphobos/libdruntime/core/stdcpp/string_view.d b/libphobos/libdruntime/core/stdcpp/string_view.d index 47f58b0..fd79a12 100644 --- a/libphobos/libdruntime/core/stdcpp/string_view.d +++ b/libphobos/libdruntime/core/stdcpp/string_view.d @@ -99,7 +99,7 @@ private: alias __data = _Mydata; alias __size = _Mysize; } - else version (CppRuntime_Gcc) + else version (CppRuntime_GNU) { size_t _M_len; const(T)* _M_str; @@ -107,7 +107,7 @@ private: alias __data = _M_str; alias __size = _M_len; } - else version (CppRuntime_Clang) + else version (CppRuntime_LLVM) { const value_type* __data; size_type __size; diff --git a/libphobos/libdruntime/core/stdcpp/typeinfo.d b/libphobos/libdruntime/core/stdcpp/typeinfo.d index b8478b3..463a813 100644 --- a/libphobos/libdruntime/core/stdcpp/typeinfo.d +++ b/libphobos/libdruntime/core/stdcpp/typeinfo.d @@ -56,7 +56,7 @@ version (CppRuntime_Microsoft) //virtual ~this(); } } -else version (CppRuntime_Gcc) +else version (CppRuntime_GNU) { import core.stdcpp.exception; @@ -110,7 +110,7 @@ else version (CppRuntime_Gcc) @weak override const(char)* what() const nothrow { return "bad typeid"; } } } -else version (CppRuntime_Clang) +else version (CppRuntime_LLVM) { import core.stdcpp.exception; diff --git a/libphobos/libdruntime/core/stdcpp/xutility.d b/libphobos/libdruntime/core/stdcpp/xutility.d index 0142d0b9..5e2e711 100644 --- a/libphobos/libdruntime/core/stdcpp/xutility.d +++ b/libphobos/libdruntime/core/stdcpp/xutility.d @@ -13,7 +13,7 @@ module core.stdcpp.xutility; @nogc: -version (CppRuntime_Clang) +version (CppRuntime_LLVM) { import core.internal.traits : AliasSeq; enum StdNamespace = AliasSeq!("std", "__1"); @@ -349,7 +349,7 @@ package: void _Xoverflow_error(const(char)* message) nothrow; void _Xruntime_error(const(char)* message) nothrow; } -else version (CppRuntime_Clang) +else version (CppRuntime_LLVM) { import core.stdcpp.type_traits : is_empty; @@ -379,7 +379,7 @@ extern(C++, "std"): @property ref inout(_T2) __value2_() inout nothrow @trusted @nogc { return *__get_base2(); } } } -version (CppRuntime_Gcc) +version (CppRuntime_GNU) { import core.atomic; diff --git a/libphobos/libdruntime/core/sys/posix/dirent.d b/libphobos/libdruntime/core/sys/posix/dirent.d index c7e8649..cb76573 100644 --- a/libphobos/libdruntime/core/sys/posix/dirent.d +++ b/libphobos/libdruntime/core/sys/posix/dirent.d @@ -42,7 +42,18 @@ struct dirent } */ -version (linux) +version (CRuntime_Bionic) +{ + struct dirent + { + ulong d_ino; + long d_off; + ushort d_reclen; + ubyte d_type; + char[256] d_name = 0; + } +} +else version (linux) { struct dirent { diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d index f457c1f..76542c6 100644 --- a/libphobos/libdruntime/core/sys/posix/dlfcn.d +++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d @@ -372,12 +372,20 @@ else version (Solaris) } else version (CRuntime_Bionic) { - enum + enum RTLD_LOCAL = 0; + enum RTLD_LAZY = 0x00001; + enum RTLD_NOLOAD = 0x00004; + enum RTLD_NODELETE = 0x01000; + + version (D_LP64) + { + enum RTLD_NOW = 0x00002; + enum RTLD_GLOBAL = 0x00100; + } + else // NDK: 'LP32 is broken for historical reasons' { - RTLD_NOW = 0, - RTLD_LAZY = 1, - RTLD_LOCAL = 0, - RTLD_GLOBAL = 2 + enum RTLD_NOW = 0; + enum RTLD_GLOBAL = 0x00002; } int dladdr(const scope void*, Dl_info*); diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index b89478f..328f620 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -33,6 +33,11 @@ version (RISCV64) version = RISCV_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; +// Android uses 64-bit offsets for stat, but 32-bit offsets for most +// other types on 32-bit architectures. +version (CRuntime_Bionic) + private enum __USE_FILE_OFFSET64 = true; + version (Posix): extern (C) nothrow @nogc: diff --git a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d index eae0e5c..9405a6d 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d +++ b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d @@ -84,7 +84,57 @@ version (CRuntime_Glibc) { int statvfs (const char * file, statvfs_t* buf); int fstatvfs (int fildes, statvfs_t *buf); } +} +else version (CRuntime_Musl) +{ + struct statvfs_t + { + c_ulong f_bsize; + c_ulong f_frsize; + fsblkcnt_t f_blocks; + fsblkcnt_t f_bfree; + fsblkcnt_t f_bavail; + fsfilcnt_t f_files; + fsfilcnt_t f_ffree; + fsfilcnt_t f_favail; + static if (true /+__BYTE_ORDER == __LITTLE_ENDIAN+/) + { + c_ulong f_fsid; + byte[2*int.sizeof-c_long.sizeof] __padding; + } + else + { + byte[2*int.sizeof-c_long.sizeof] __padding; + c_ulong f_fsid; + } + c_ulong f_flag; + c_ulong f_namemax; + uint f_type; + int[5] __reserved; + } + + enum FFlag + { + ST_RDONLY = 1, /* Mount read-only. */ + ST_NOSUID = 2, + ST_NODEV = 4, /* Disallow access to device special files. */ + ST_NOEXEC = 8, /* Disallow program execution. */ + ST_SYNCHRONOUS = 16, /* Writes are synced at once. */ + ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ + ST_WRITE = 128, /* Write on file/directory/symlink. */ + ST_APPEND = 256, /* Append-only file. */ + ST_IMMUTABLE = 512, /* Immutable file. */ + ST_NOATIME = 1024, /* Do not update access times. */ + ST_NODIRATIME = 2048, /* Do not update directory access times. */ + ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */ + + } + + int statvfs (const char * file, statvfs_t* buf); + int fstatvfs (int fildes, statvfs_t *buf); + alias statvfs statvfs64; + alias fstatvfs fstatvfs64; } else version (NetBSD) { diff --git a/libphobos/libdruntime/core/sys/windows/stacktrace.d b/libphobos/libdruntime/core/sys/windows/stacktrace.d index 29ffc1b..04aafd3f 100644 --- a/libphobos/libdruntime/core/sys/windows/stacktrace.d +++ b/libphobos/libdruntime/core/sys/windows/stacktrace.d @@ -48,9 +48,9 @@ public: if (context is null) { version (Win64) - static enum INTERNALFRAMES = 3; + enum INTERNALFRAMES = 3; else version (Win32) - static enum INTERNALFRAMES = 2; + enum INTERNALFRAMES = 2; skip += INTERNALFRAMES; //skip the stack frames within the StackTrace class } @@ -58,9 +58,9 @@ public: { //When a exception context is given the first stack frame is repeated for some reason version (Win64) - static enum INTERNALFRAMES = 1; + enum INTERNALFRAMES = 1; else version (Win32) - static enum INTERNALFRAMES = 1; + enum INTERNALFRAMES = 1; skip += INTERNALFRAMES; } diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d index 0bdb45a..3070481 100644 --- a/libphobos/libdruntime/core/thread/osthread.d +++ b/libphobos/libdruntime/core/thread/osthread.d @@ -2211,7 +2211,7 @@ extern (C) void thread_init() @nogc nothrow status = sem_init( &suspendCount, 0, 0 ); assert( status == 0 ); } - _mainThreadStore[] = __traits(initSymbol, Thread)[]; + _mainThreadStore[] = cast(void[]) __traits(initSymbol, Thread)[]; Thread.sm_main = attachThread((cast(Thread)_mainThreadStore.ptr).__ctor()); } diff --git a/libphobos/libdruntime/core/thread/threadbase.d b/libphobos/libdruntime/core/thread/threadbase.d index f593387..58dd259 100644 --- a/libphobos/libdruntime/core/thread/threadbase.d +++ b/libphobos/libdruntime/core/thread/threadbase.d @@ -778,7 +778,7 @@ package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _main // destruct manually as object.destroy is not @nogc (cast(ThreadT) cast(void*) ThreadBase.sm_main).__dtor(); _d_monitordelete_nogc(ThreadBase.sm_main); - _mainThreadStore[] = __traits(initSymbol, ThreadT)[]; + _mainThreadStore[] = cast(void[]) __traits(initSymbol, ThreadT)[]; ThreadBase.sm_main = null; assert(ThreadBase.sm_tbeg && ThreadBase.sm_tlen == 1); diff --git a/libphobos/libdruntime/gcc/sections/elf.d b/libphobos/libdruntime/gcc/sections/elf.d index 1a3ff40..bbebedf 100644 --- a/libphobos/libdruntime/gcc/sections/elf.d +++ b/libphobos/libdruntime/gcc/sections/elf.d @@ -162,17 +162,10 @@ private: } /**** - * Boolean flag set to true while the runtime is initialized. - */ -__gshared bool _isRuntimeInitialized; - - -/**** * Gets called on program startup just before GC is initialized. */ void initSections() nothrow @nogc { - _isRuntimeInitialized = true; } @@ -181,7 +174,6 @@ void initSections() nothrow @nogc */ void finiSections() nothrow @nogc { - _isRuntimeInitialized = false; } alias ScanDG = void delegate(void* pbeg, void* pend) nothrow; @@ -482,7 +474,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) } // don't initialize modules before rt_init was called (see Bugzilla 11378) - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { registerGCRanges(pdso); // rt_loadLibrary will run tls ctors, so do this only for dlopen @@ -497,7 +489,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) *data._slot = null; // don't finalizes modules after rt_term was called (see Bugzilla 11378) - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { // rt_unloadLibrary already ran tls dtors, so do this only for dlclose immutable runTlsDtors = !_rtLoading; diff --git a/libphobos/libdruntime/gcc/sections/macho.d b/libphobos/libdruntime/gcc/sections/macho.d index 645c0f4..7211fa7 100644 --- a/libphobos/libdruntime/gcc/sections/macho.d +++ b/libphobos/libdruntime/gcc/sections/macho.d @@ -30,6 +30,7 @@ import core.sys.darwin.dlfcn; import core.sys.darwin.mach.dyld; import core.sys.darwin.mach.getsect; import core.sys.posix.pthread; +import rt.dmain2; import rt.minfo; import core.internal.container.array; import core.internal.container.hashtab; @@ -96,16 +97,10 @@ private: } /**** - * Boolean flag set to true while the runtime is initialized. - */ -__gshared bool _isRuntimeInitialized; - -/**** * Gets called on program startup just before GC is initialized. */ void initSections() nothrow @nogc { - _isRuntimeInitialized = true; } /*** @@ -113,7 +108,6 @@ void initSections() nothrow @nogc */ void finiSections() nothrow @nogc { - _isRuntimeInitialized = false; } alias ScanDG = void delegate(void* pbeg, void* pend) nothrow; @@ -379,7 +373,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) } // don't initialize modules before rt_init was called - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { registerGCRanges(pdso); // rt_loadLibrary will run tls ctors, so do this only for dlopen @@ -394,7 +388,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) *data._slot = null; // don't finalizes modules after rt_term was called (see Bugzilla 11378) - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { // rt_unloadLibrary already ran tls dtors, so do this only for dlclose immutable runTlsDtors = !_rtLoading; diff --git a/libphobos/libdruntime/gcc/sections/pecoff.d b/libphobos/libdruntime/gcc/sections/pecoff.d index 038e373..fb49f62 100644 --- a/libphobos/libdruntime/gcc/sections/pecoff.d +++ b/libphobos/libdruntime/gcc/sections/pecoff.d @@ -29,6 +29,7 @@ import core.stdc.stdlib; import core.sys.windows.winbase; import core.sys.windows.windef; import core.sys.windows.winnt; +import rt.dmain2; import rt.minfo; import core.internal.container.array; import core.internal.container.hashtab; @@ -95,16 +96,10 @@ private: } /**** - * Boolean flag set to true while the runtime is initialized. - */ -__gshared bool _isRuntimeInitialized; - -/**** * Gets called on program startup just before GC is initialized. */ void initSections() nothrow @nogc { - _isRuntimeInitialized = true; } /*** @@ -112,7 +107,6 @@ void initSections() nothrow @nogc */ void finiSections() nothrow @nogc { - _isRuntimeInitialized = false; } alias ScanDG = void delegate(void* pbeg, void* pend) nothrow; @@ -372,7 +366,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) } // don't initialize modules before rt_init was called - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { registerGCRanges(pdso); // rt_loadLibrary will run tls ctors, so do this only for dlopen @@ -387,7 +381,7 @@ extern(C) void _d_dso_registry(CompilerDSOData* data) *data._slot = null; // don't finalizes modules after rt_term was called (see Bugzilla 11378) - if (_isRuntimeInitialized) + if (isRuntimeInitialized()) { // rt_unloadLibrary already ran tls dtors, so do this only for dlclose immutable runTlsDtors = !_rtLoading; diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d index 5903d9c..26c16d3 100644 --- a/libphobos/libdruntime/rt/aaA.d +++ b/libphobos/libdruntime/rt/aaA.d @@ -688,7 +688,7 @@ extern (C) inout(void[]) _aaValues(inout AA aa, const size_t keysz, const size_t { if (!b.filled) continue; - pval[0 .. valsz] = b.entry[off .. valsz + off]; + pval[0 .. valsz] = cast(void[]) b.entry[off .. valsz + off]; pval += valsz; } // postblit is done in object.values @@ -710,7 +710,7 @@ extern (C) inout(void[]) _aaKeys(inout AA aa, const size_t keysz, const TypeInfo { if (!b.filled) continue; - pkey[0 .. keysz] = b.entry[0 .. keysz]; + pkey[0 .. keysz] = cast(void[]) b.entry[0 .. keysz]; pkey += keysz; } // postblit is done in object.keys diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d index 5ac053c..052b859 100644 --- a/libphobos/libdruntime/rt/dmain2.d +++ b/libphobos/libdruntime/rt/dmain2.d @@ -102,7 +102,7 @@ alias void delegate(Throwable) ExceptionHandler; /** * Keep track of how often rt_init/rt_term were called. */ -shared size_t _initCount; +private shared size_t _initCount; /********************************************** * Initialize druntime. @@ -177,6 +177,13 @@ extern (C) int rt_term() return 0; } +/** + * Indicates whether druntime has been or is being initialized. + */ +bool isRuntimeInitialized() @nogc nothrow { + return atomicLoad!(MemoryOrder.raw)(_initCount) != 0; +} + /********************************************** * Trace handler */ diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d index 4a071f3..676f88d 100644 --- a/libphobos/libdruntime/rt/lifetime.d +++ b/libphobos/libdruntime/rt/lifetime.d @@ -129,7 +129,7 @@ extern (C) Object _d_newclass(const ClassInfo ci) @weak } // initialize it - p[0 .. init.length] = init[]; + p[0 .. init.length] = cast(void[]) init[]; debug(PRINTF) printf("initialization done\n"); return cast(Object) p; @@ -1294,7 +1294,7 @@ extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true) if (resetMemory) { auto w = (*pc).initializer; - p[0 .. w.length] = w[]; + p[0 .. w.length] = cast(void[]) w[]; } } catch (Exception e) diff --git a/libphobos/libdruntime/rt/sections.d b/libphobos/libdruntime/rt/sections.d index 6a15552..a7b75d4ba 100644 --- a/libphobos/libdruntime/rt/sections.d +++ b/libphobos/libdruntime/rt/sections.d @@ -57,7 +57,7 @@ else version (Darwin) else version (CRuntime_Microsoft) public import rt.sections_win64; else version (CRuntime_Bionic) - public import rt.sections_android; + public import rt.sections_elf_shared; else version (CRuntime_UClibc) public import rt.sections_elf_shared; else diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index a431ca1..46e2443 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -de1dea109f40fe4a551578369c474e48845daec1 +0c28620c301c9ae3136b1e1e5af55c290dbc7aae The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am index d45d116..a8a5ed3 100644 --- a/libphobos/src/Makefile.am +++ b/libphobos/src/Makefile.am @@ -138,18 +138,18 @@ PHOBOS_DSOURCES = etc/c/curl.d etc/c/zlib.d std/algorithm/comparison.d \ std/internal/math/errorfunction.d std/internal/math/gammafunction.d \ std/internal/memory.d std/internal/scopebuffer.d \ std/internal/test/dummyrange.d std/internal/test/range.d \ - std/internal/test/uda.d std/internal/unicode_comp.d \ - std/internal/unicode_decomp.d std/internal/unicode_grapheme.d \ - std/internal/unicode_norm.d std/internal/unicode_tables.d \ - std/internal/windows/advapi32.d std/json.d std/logger/core.d \ - std/logger/filelogger.d std/logger/multilogger.d \ - std/logger/nulllogger.d std/logger/package.d std/math/algebraic.d \ - std/math/constants.d std/math/exponential.d std/math/hardware.d \ - std/math/operations.d std/math/package.d std/math/remainder.d \ - std/math/rounding.d std/math/traits.d std/math/trigonometry.d \ - std/mathspecial.d std/meta.d std/mmfile.d std/net/curl.d \ - std/net/isemail.d std/numeric.d std/outbuffer.d std/package.d \ - std/parallelism.d std/path.d std/process.d std/random.d \ + std/internal/test/sumtype_example_overloads.d std/internal/test/uda.d \ + std/internal/unicode_comp.d std/internal/unicode_decomp.d \ + std/internal/unicode_grapheme.d std/internal/unicode_norm.d \ + std/internal/unicode_tables.d std/internal/windows/advapi32.d \ + std/json.d std/logger/core.d std/logger/filelogger.d \ + std/logger/multilogger.d std/logger/nulllogger.d std/logger/package.d \ + std/math/algebraic.d std/math/constants.d std/math/exponential.d \ + std/math/hardware.d std/math/operations.d std/math/package.d \ + std/math/remainder.d std/math/rounding.d std/math/traits.d \ + std/math/trigonometry.d std/mathspecial.d std/meta.d std/mmfile.d \ + std/net/curl.d std/net/isemail.d std/numeric.d std/outbuffer.d \ + std/package.d std/parallelism.d std/path.d std/process.d std/random.d \ std/range/interfaces.d std/range/package.d std/range/primitives.d \ std/regex/internal/backtracking.d std/regex/internal/generator.d \ std/regex/internal/ir.d std/regex/internal/kickstart.d \ diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index cc3358b..52f2d1a 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -237,6 +237,7 @@ am__dirstamp = $(am__leading_dot)dirstamp @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/scopebuffer.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/dummyrange.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/range.lo \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/sumtype_example_overloads.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/uda.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_comp.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_decomp.lo \ @@ -599,18 +600,18 @@ libgphobos_la_LINK = $(LIBTOOL) --tag=D $(libgphobos_la_LIBTOOLFLAGS) \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/math/errorfunction.d std/internal/math/gammafunction.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/memory.d std/internal/scopebuffer.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/dummyrange.d std/internal/test/range.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/uda.d std/internal/unicode_comp.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_decomp.d std/internal/unicode_grapheme.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_norm.d std/internal/unicode_tables.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/windows/advapi32.d std/json.d std/logger/core.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/logger/filelogger.d std/logger/multilogger.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/logger/nulllogger.d std/logger/package.d std/math/algebraic.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/constants.d std/math/exponential.d std/math/hardware.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/operations.d std/math/package.d std/math/remainder.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/rounding.d std/math/traits.d std/math/trigonometry.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/mathspecial.d std/meta.d std/mmfile.d std/net/curl.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/net/isemail.d std/numeric.d std/outbuffer.d std/package.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/parallelism.d std/path.d std/process.d std/random.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/test/sumtype_example_overloads.d std/internal/test/uda.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_comp.d std/internal/unicode_decomp.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_grapheme.d std/internal/unicode_norm.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/unicode_tables.d std/internal/windows/advapi32.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/json.d std/logger/core.d std/logger/filelogger.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/logger/multilogger.d std/logger/nulllogger.d std/logger/package.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/algebraic.d std/math/constants.d std/math/exponential.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/hardware.d std/math/operations.d std/math/package.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/remainder.d std/math/rounding.d std/math/traits.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/math/trigonometry.d std/mathspecial.d std/meta.d std/mmfile.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/net/curl.d std/net/isemail.d std/numeric.d std/outbuffer.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/package.d std/parallelism.d std/path.d std/process.d std/random.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/range/interfaces.d std/range/package.d std/range/primitives.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/regex/internal/backtracking.d std/regex/internal/generator.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/regex/internal/ir.d std/regex/internal/kickstart.d \ @@ -868,6 +869,8 @@ std/internal/test/$(am__dirstamp): @: > std/internal/test/$(am__dirstamp) std/internal/test/dummyrange.lo: std/internal/test/$(am__dirstamp) std/internal/test/range.lo: std/internal/test/$(am__dirstamp) +std/internal/test/sumtype_example_overloads.lo: \ + std/internal/test/$(am__dirstamp) std/internal/test/uda.lo: std/internal/test/$(am__dirstamp) std/internal/unicode_comp.lo: std/internal/$(am__dirstamp) std/internal/unicode_decomp.lo: std/internal/$(am__dirstamp) diff --git a/libphobos/src/std/format/spec.d b/libphobos/src/std/format/spec.d index b129686..e5564c9 100644 --- a/libphobos/src/std/format/spec.d +++ b/libphobos/src/std/format/spec.d @@ -681,7 +681,7 @@ if (is(Unqual!Char == Char)) auto fmt = "Number: %6.4e\nString: %s"; auto f = FormatSpec!char(fmt); - assert(f.writeUpToNextSpec(a) == true); + assert(f.writeUpToNextSpec(a)); assert(a.data == "Number: "); assert(f.trailing == "\nString: %s"); @@ -689,13 +689,13 @@ if (is(Unqual!Char == Char)) assert(f.width == 6); assert(f.precision == 4); - assert(f.writeUpToNextSpec(a) == true); + assert(f.writeUpToNextSpec(a)); assert(a.data == "Number: \nString: "); assert(f.trailing == ""); assert(f.spec == 's'); - assert(f.writeUpToNextSpec(a) == false); + assert(!f.writeUpToNextSpec(a)); assert(a.data == "Number: \nString: "); } diff --git a/libphobos/src/std/internal/test/sumtype_example_overloads.d b/libphobos/src/std/internal/test/sumtype_example_overloads.d new file mode 100644 index 0000000..235659d --- /dev/null +++ b/libphobos/src/std/internal/test/sumtype_example_overloads.d @@ -0,0 +1,17 @@ +/++ +For testing only. + +Overload set used in std.sumtype example. Needs its own internal module so that +it can be available for `make publictests` without polluting the public API. ++/ +module std.internal.test.sumtype_example_overloads; + +import std.sumtype; + +@safe +{ + string handle(int) { return "got an int"; } + string handle(string) { return "got a string"; } + string handle(double) { return "got a double"; } + alias handle = match!handle; +} diff --git a/libphobos/src/std/math/exponential.d b/libphobos/src/std/math/exponential.d index 5e90f0d..8fcd88f 100644 --- a/libphobos/src/std/math/exponential.d +++ b/libphobos/src/std/math/exponential.d @@ -256,7 +256,7 @@ if (isFloatingPoint!(F) && isIntegral!(G)) * If x is 0 and n is negative, the result is the same as the result of a * division by zero. */ -typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pure nothrow +typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @safe pure nothrow if (isIntegral!(F) && isIntegral!(G)) { import std.traits : isSigned; diff --git a/libphobos/src/std/net/curl.d b/libphobos/src/std/net/curl.d index 3f82301..07905fc 100644 --- a/libphobos/src/std/net/curl.d +++ b/libphobos/src/std/net/curl.d @@ -1063,7 +1063,7 @@ private auto _basicHTTP(T)(const(char)[] url, const(void)[] sendData, HTTP clien { size_t minLen = min(buf.length, remainingData.length); if (minLen == 0) return 0; - buf[0 .. minLen] = remainingData[0 .. minLen]; + buf[0 .. minLen] = cast(void[]) remainingData[0 .. minLen]; remainingData = remainingData[minLen..$]; return minLen; }; @@ -1202,7 +1202,7 @@ private auto _basicFTP(T)(const(char)[] url, const(void)[] sendData, FTP client) { size_t minLen = min(buf.length, sendData.length); if (minLen == 0) return 0; - buf[0 .. minLen] = sendData[0 .. minLen]; + buf[0 .. minLen] = cast(void[]) sendData[0 .. minLen]; sendData = sendData[minLen..$]; return minLen; }; diff --git a/libphobos/src/std/range/package.d b/libphobos/src/std/range/package.d index 995bf1e..b6fddf7 100644 --- a/libphobos/src/std/range/package.d +++ b/libphobos/src/std/range/package.d @@ -13539,10 +13539,10 @@ if (isInputRange!R && isIntegral!(ElementType!R)) { size_t bitsNum = IntegralType.sizeof * 8; - auto first = cast(IntegralType)(1); + auto first = IntegralType(1); // 2 ^ (bitsNum - 1) - auto second = cast(IntegralType)(cast(IntegralType)(1) << (bitsNum - 2)); + auto second = cast(IntegralType)(IntegralType(1) << (bitsNum - 2)); IntegralType[] a = [first, second]; auto bw = Bitwise!(IntegralType[])(a); @@ -13571,7 +13571,7 @@ if (isInputRange!R && isIntegral!(ElementType!R)) auto bw2 = bw[0 .. $ - 5]; auto bw3 = bw2[]; - assert(bw2.length == (bw.length - 5)); + assert(bw2.length == bw.length - 5); assert(bw2.length == bw3.length); bw2.popFront(); assert(bw2.length != bw3.length); diff --git a/libphobos/src/std/string.d b/libphobos/src/std/string.d index b350d6b..21e1ca3 100644 --- a/libphobos/src/std/string.d +++ b/libphobos/src/std/string.d @@ -6331,42 +6331,42 @@ if (isSomeString!S || assertCTFEable!( { // Test the isNumeric(in string) function - assert(isNumeric("1") == true ); - assert(isNumeric("1.0") == true ); - assert(isNumeric("1e-1") == true ); - assert(isNumeric("12345xxxx890") == false ); - assert(isNumeric("567L") == true ); - assert(isNumeric("23UL") == true ); - assert(isNumeric("-123..56f") == false ); - assert(isNumeric("12.3.5.6") == false ); - assert(isNumeric(" 12.356") == false ); - assert(isNumeric("123 5.6") == false ); - assert(isNumeric("1233E-1+1.0e-1i") == true ); - - assert(isNumeric("123.00E-5+1234.45E-12Li") == true); - assert(isNumeric("123.00e-5+1234.45E-12iL") == false); - assert(isNumeric("123.00e-5+1234.45e-12uL") == false); - assert(isNumeric("123.00E-5+1234.45e-12lu") == false); - - assert(isNumeric("123fi") == true); - assert(isNumeric("123li") == true); - assert(isNumeric("--123L") == false); - assert(isNumeric("+123.5UL") == false); - assert(isNumeric("123f") == true); - assert(isNumeric("123.u") == false); + assert(isNumeric("1")); + assert(isNumeric("1.0")); + assert(isNumeric("1e-1")); + assert(!isNumeric("12345xxxx890")); + assert(isNumeric("567L")); + assert(isNumeric("23UL")); + assert(!isNumeric("-123..56f")); + assert(!isNumeric("12.3.5.6")); + assert(!isNumeric(" 12.356")); + assert(!isNumeric("123 5.6")); + assert(isNumeric("1233E-1+1.0e-1i")); + + assert(isNumeric("123.00E-5+1234.45E-12Li")); + assert(!isNumeric("123.00e-5+1234.45E-12iL")); + assert(!isNumeric("123.00e-5+1234.45e-12uL")); + assert(!isNumeric("123.00E-5+1234.45e-12lu")); + + assert(isNumeric("123fi")); + assert(isNumeric("123li")); + assert(!isNumeric("--123L")); + assert(!isNumeric("+123.5UL")); + assert(isNumeric("123f")); + assert(!isNumeric("123.u")); // @@@BUG@@ to!string(float) is not CTFEable. // Related: formatValue(T) if (is(FloatingPointTypeOf!T)) if (!__ctfe) { - assert(isNumeric(to!string(real.nan)) == true); - assert(isNumeric(to!string(-real.infinity)) == true); + assert(isNumeric(to!string(real.nan))); + assert(isNumeric(to!string(-real.infinity))); } string s = "$250.99-"; - assert(isNumeric(s[1 .. s.length - 2]) == true); - assert(isNumeric(s) == false); - assert(isNumeric(s[0 .. s.length - 1]) == false); + assert(isNumeric(s[1 .. $ - 2])); + assert(!isNumeric(s)); + assert(!isNumeric(s[0 .. $ - 1])); }); assert(!isNumeric("-")); diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d index 80ce73d..69c2a49 100644 --- a/libphobos/src/std/sumtype.d +++ b/libphobos/src/std/sumtype.d @@ -11,6 +11,15 @@ include: * No dependency on runtime type information (`TypeInfo`). * Compatibility with BetterC. +$(H3 List of examples) + +* [Basic usage](#basic-usage) +* [Matching with an overload set](#matching-with-an-overload-set) +* [Recursive SumTypes](#recursive-sumtypes) +* [Memory corruption](#memory-corruption) (why assignment can be `@system`) +* [Avoiding unintentional matches](#avoiding-unintentional-matches) +* [Multiple dispatch](#multiple-dispatch) + License: Boost License 1.0 Authors: Paul Backus Source: $(PHOBOSSRC std/sumtype.d) @@ -77,52 +86,38 @@ version (D_BetterC) {} else assert(!isFahrenheit(t3)); } -/** $(DIVID introspection-based-matching, $(H3 Introspection-based matching)) +/** $(DIVID matching-with-an-overload-set, $(H3 Matching with an overload set)) + * + * Instead of writing `match` handlers inline as lambdas, you can write them as + * overloads of a function. An `alias` can be used to create an additional + * overload for the `SumType` itself. + * + * For example, with this overload set: * - * In the `length` and `horiz` functions below, the handlers for `match` do not - * specify the types of their arguments. Instead, matching is done based on how - * the argument is used in the body of the handler: any type with `x` and `y` - * properties will be matched by the `rect` handlers, and any type with `r` and - * `theta` properties will be matched by the `polar` handlers. + * --- + * string handle(int n) { return "got an int"; } + * string handle(string s) { return "got a string"; } + * string handle(double d) { return "got a double"; } + * alias handle = match!handle; + * --- + * + * Usage would look like this: */ version (D_BetterC) {} else @safe unittest { - import std.math.operations : isClose; - import std.math.trigonometry : cos; - import std.math.constants : PI; - import std.math.algebraic : sqrt; - - struct Rectangular { double x, y; } - struct Polar { double r, theta; } - alias Vector = SumType!(Rectangular, Polar); - - double length(Vector v) - { - return v.match!( - rect => sqrt(rect.x^^2 + rect.y^^2), - polar => polar.r - ); - } - - double horiz(Vector v) - { - return v.match!( - rect => rect.x, - polar => polar.r * cos(polar.theta) - ); - } + alias ExampleSumType = SumType!(int, string, double); - Vector u = Rectangular(1, 1); - Vector v = Polar(1, PI/4); + ExampleSumType a = 123; + ExampleSumType b = "hello"; + ExampleSumType c = 3.14; - assert(length(u).isClose(sqrt(2.0))); - assert(length(v).isClose(1)); - assert(horiz(u).isClose(1)); - assert(horiz(v).isClose(sqrt(0.5))); + assert(a.handle == "got an int"); + assert(b.handle == "got a string"); + assert(c.handle == "got a double"); } -/** $(DIVID arithmetic-expression-evaluator, $(H3 Arithmetic expression evaluator)) +/** $(DIVID recursive-sumtypes, $(H3 Recursive SumTypes)) * * This example makes use of the special placeholder type `This` to define a * [recursive data type](https://en.wikipedia.org/wiki/Recursive_data_type): an @@ -227,6 +222,10 @@ version (D_BetterC) {} else assert(pprint(*myExpr) == "(a + (2 * b))"); } +// For the "Matching with an overload set" example above +// Needs public import to work with `make publictests` +version (unittest) public import std.internal.test.sumtype_example_overloads; + import std.format.spec : FormatSpec, singleSpec; import std.meta : AliasSeq, Filter, IndexOf = staticIndexOf, Map = staticMap; import std.meta : NoDuplicates; @@ -266,8 +265,7 @@ private enum isInout(T) = is(T == inout); * * The special type `This` can be used as a placeholder to create * self-referential types, just like with `Algebraic`. See the - * ["Arithmetic expression evaluator" example](#arithmetic-expression-evaluator) for - * usage. + * ["Recursive SumTypes" example](#recursive-sumtypes) for usage. * * A `SumType` is initialized by default to hold the `.init` value of its * first member type, just like a regular union. The version identifier @@ -1619,9 +1617,9 @@ enum bool isSumType(T) = is(T : SumType!Args, Args...); * overloads are considered as potential matches. * * Templated handlers are also accepted, and will match any type for which they - * can be [implicitly instantiated](https://dlang.org/glossary.html#ifti). See - * ["Introspection-based matching"](#introspection-based-matching) for an - * example of templated handler usage. + * can be [implicitly instantiated](https://dlang.org/glossary.html#ifti). + * (Remember that a $(DDSUBLINK spec/expression,function_literals, function literal) + * without an explicit argument type is considered a template.) * * If multiple [SumType]s are passed to match, their values are passed to the * handlers as separate arguments, and matching is done for each possible diff --git a/libphobos/src/std/utf.d b/libphobos/src/std/utf.d index c0cd386..f0d5d4d 100644 --- a/libphobos/src/std/utf.d +++ b/libphobos/src/std/utf.d @@ -2528,8 +2528,8 @@ size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( encode(buf, '\u0000'); assert(buf[0] == '\u0000'); encode(buf, '\uD7FF'); assert(buf[0] == '\uD7FF'); encode(buf, '\uE000'); assert(buf[0] == '\uE000'); - encode(buf, 0xFFFE ); assert(buf[0] == 0xFFFE); - encode(buf, 0xFFFF ); assert(buf[0] == 0xFFFF); + encode(buf, 0xFFFE); assert(buf[0] == 0xFFFE); + encode(buf, 0xFFFF); assert(buf[0] == 0xFFFF); encode(buf, '\U0010FFFF'); assert(buf[0] == '\U0010FFFF'); assertThrown!UTFException(encode(buf, cast(dchar) 0xD800)); @@ -2749,8 +2749,8 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( encode(buf, '\u0000'); assert(buf[0] == '\u0000'); encode(buf, '\uD7FF'); assert(buf[1] == '\uD7FF'); encode(buf, '\uE000'); assert(buf[2] == '\uE000'); - encode(buf, 0xFFFE ); assert(buf[3] == 0xFFFE); - encode(buf, 0xFFFF ); assert(buf[4] == 0xFFFF); + encode(buf, 0xFFFE); assert(buf[3] == 0xFFFE); + encode(buf, 0xFFFF); assert(buf[4] == 0xFFFF); encode(buf, '\U0010FFFF'); assert(buf[5] == '\U0010FFFF'); assertThrown!UTFException(encode(buf, cast(dchar) 0xD800)); |