Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9270883
Add std.sumtype
pbackus Nov 15, 2020
6d304b2
std.sumtype: make style checks pass
pbackus Nov 16, 2020
cc05497
Allow testing full modules with -betterC
pbackus Nov 16, 2020
73b160e
std.sumtype: convert docs to ddoc syntax
pbackus Nov 16, 2020
92b46af
Fix inconsistent naming of template this parameter
pbackus Nov 21, 2020
2229f07
Add std.sumtype to index.d
pbackus Nov 21, 2020
1240230
Recommend SumType as an alternative to Algebraic
pbackus Nov 21, 2020
c1626c5
std.sumtype: convert stray tabs to spaces
pbackus Nov 21, 2020
7dc3e6e
std.sumtype: remove function attributes from examples
pbackus Nov 26, 2020
03a7d84
std.sumtype: link to definition of tagged union
pbackus Nov 26, 2020
43c1ec2
std.sumtype: upstream improvements from v1.0.1
pbackus Dec 4, 2020
c60702c
Add test runner for full-module BetterC tests
pbackus Dec 4, 2020
61ba1f6
std.sumtype: upstream improvements from v1.0.2 and v1.0.3
pbackus Jan 26, 2021
abe9f82
Use alphabetical order in .dscanner.ini entries
pbackus Jan 26, 2021
d4d1e66
std.sumtype: remove copy of isRvalueAssignable
pbackus Jan 29, 2021
d5d51c2
Improve wording of warning about Algebraic in docs
pbackus Jan 29, 2021
b9e9730
Add std/sumtype.d to CODEOWNERS
pbackus Jan 29, 2021
ead2e63
std.sumtype: add URLs for bugzilla issues
pbackus Feb 20, 2021
99890f7
std.sumtype: Remove useless variables from unittest
pbackus Feb 20, 2021
d6aff90
std.sumtype: Document why some tests are BetterC-ineligible
pbackus Feb 20, 2021
7dfc0c4
std.sumtype: explain purpose of toCtString test
pbackus Feb 20, 2021
9bc6479
std.sumtype: don't use assert(__traits(compiles))
pbackus Feb 27, 2021
2b1bbbd
std.sumtype: fix broken BetterC tests
pbackus Feb 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .dscanner.ini
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ assert_without_msg="-etc.c.SQL_,\
-std.socket,\
-std.stdio,\
-std.string,\
-std.sumtype,\
Copy link
Contributor Author

@pbackus pbackus Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale for these disabled checks, copy+pasted from the relevant commit message:

  • assert_without_message: flags asserts inside invariants, even though
    their messages are ignored.
  • could_be_immutable_check: flags variables inside unittest blocks.
  • has_public_examples: flags SumType because its examples are attached
    to the module rather than the SumType symbol itself.
  • object_const_check: does not acknowledge a template this parameter as
    a valid alternative to inout on opEquals and toString.
  • opequals_tohash_check: fails to detect SumType.toHash.
  • properly_documented_functions: requires 'Params' documentation for
    template this parameters and parameters of private (but documented)
    functions.

-std.traits,\
-std.typecons,\
-std.uni,\
Expand All @@ -211,7 +212,7 @@ assert_without_msg="-etc.c.SQL_,\
; Checks for assignment to auto-ref function parameters
auto_ref_assignment_check="-std.algorithm.mutation,-std.format,-std.typecons"
; Checks for variables that could be declared immutable
could_be_immutable_check="-std.algorithm.comparison,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.base64,-std.bigint,-std.bitmanip,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.container.util,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.digest.crc,-std.digest,-std.digest.hmac,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.logger.multilogger,-std.experimental.typecons,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.mathspecial,-std.meta,-std.mmfile,-std.net.curl,-std.net.isemail,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.xml,-std.zip,-std.zlib"
could_be_immutable_check="-std.algorithm.comparison,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.base64,-std.bigint,-std.bitmanip,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.container.util,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.digest.crc,-std.digest,-std.digest.hmac,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.logger.multilogger,-std.experimental.typecons,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.mathspecial,-std.meta,-std.mmfile,-std.net.curl,-std.net.isemail,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.sumtype,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.xml,-std.zip,-std.zlib"
; Check for poor exception handling practices
exception_check="-std.concurrency,-std.net.curl,-std.parallelism,-std.range,-std.socket,-std.typecons"
; Checks for poor placement of function attributes
Expand Down Expand Up @@ -266,6 +267,7 @@ has_public_example="-etc.c.curl,\
-std.regex.internal.ir,\
-std.socket,\
-std.stdio,\
-std.sumtype,\
-std.uni,\
-std.xml,\
-std.zip,\
Expand All @@ -290,9 +292,9 @@ number_style_check="+disabled"
;number_style_check="-std.algorithm.iteration,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.container.array,-std.conv,-std.datetime.date,-std.datetime.systime,-std.datetime.timezone,-std.digest.crc,-std.digest,-std.digest.md,-std.digest.ripemd,-std.digest.sha,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.checkedint,-std.file,-std.format,-std.functional,-std.internal.math.biguintcore,-std.internal.math.gammafunction,-std.json,-std.math,-std.outbuffer,-std.parallelism,-std.random,-std.range,-std.regex.internal.generator,-std.utf,-std.zip,-std.zlib"
; Checks that opEquals, opCmp, toHash, and toString are either const, immutable
; , or inout.
object_const_check="-std.algorithm.searching,-std.array,-std.bitmanip,-std.concurrency,-std.container.rbtree,-std.conv,-std.datetime.interval,-std.encoding,-std.exception,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.typecons,-std.format,-std.functional,-std.meta,-std.numeric,-std.range,-std.regex,-std.stdio,-std.typecons,-std.variant,-std.xml"
object_const_check="-std.algorithm.searching,-std.array,-std.bitmanip,-std.concurrency,-std.container.rbtree,-std.conv,-std.datetime.interval,-std.encoding,-std.exception,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.typecons,-std.format,-std.functional,-std.meta,-std.numeric,-std.range,-std.regex,-std.stdio,-std.sumtype,-std.typecons,-std.variant,-std.xml"
; Checks that opEquals and toHash are both defined or neither are defined
opequals_tohash_check="-std.complex,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.datetime,-std.datetime.date,-std.experimental.checkedint,-std.internal.test.dummyrange,-std.json,-std.numeric,-std.random,-std.socket,-std.typecons,-std.uni"
opequals_tohash_check="-std.complex,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.datetime,-std.datetime.date,-std.experimental.checkedint,-std.internal.test.dummyrange,-std.json,-std.numeric,-std.random,-std.socket,-std.sumtype,-std.typecons,-std.uni"
; Check for properly documented public functions (Returns, Params)
; Note: DScanner doesn't understand documenting parameters of IFTI/eponymous templates.
properly_documented_public_functions="-etc.c.odbc.sql,\
Expand Down Expand Up @@ -383,6 +385,7 @@ properly_documented_public_functions="-etc.c.odbc.sql,\
-std.socket,\
-std.stdio,\
-std.string,\
-std.sumtype,\
-std.typecons,\
-std.uni,\
-std.uri,\
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ std/socket.d @CyberShadow @klickverbot
# std/stdint.d
std/stdio.d @CyberShadow @schveiguy
std/string.d @burner @JackStouffer
std/sumtype.d @pbackus
# std/system.d
std/traits.d @Biotronic @klickverbot @ZombineDev
std/typecons.d @Biotronic @MetaLang @ZombineDev
Expand Down
6 changes: 5 additions & 1 deletion index.d
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,16 @@ $(BOOKTABLE ,
)
$(TR
$(TDNW $(MREF std,variant))
$(TD Discriminated unions and algebraic types.)
$(TD Dynamically-typed variable that can hold a value of any type.)
)
$(TR
$(TDNW $(MREF core,bitop))
$(TD Low level bit manipulation.)
)
$(TR
$(TDNW $(MREF std,sumtype))
$(TD Type-safe discriminated union.)
)
$(LEADINGROW Vector programming)
$(TR
$(TDNW $(MREF core,simd))
Expand Down
23 changes: 22 additions & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ PACKAGE_std = array ascii base64 bigint bitmanip compiler complex concurrency \
conv csv demangle encoding exception file \
functional getopt json math mathspecial meta mmfile numeric \
outbuffer package parallelism path process random signals socket stdint \
stdio string system traits typecons \
stdio string sumtype system traits typecons \
uri utf uuid variant xml zip zlib
PACKAGE_std_experimental = checkedint typecons
PACKAGE_std_algorithm = comparison iteration mutation package searching setops \
Expand Down Expand Up @@ -670,6 +670,27 @@ betterc: betterc-phobos-tests
--inputdir $< --outputdir $(BETTERCTESTS_DIR)
$(DMD) $(DFLAGS) $(NODEFAULTLIB) -betterC -unittest -run $(BETTERCTESTS_DIR)/$(subst /,_,$<)


################################################################################
# Full-module BetterC tests
# -------------------------
#
# Test full modules with -betterC. Edit BETTERC_MODULES and
# test/betterc_module_tests.d to add new modules to the list.
Comment on lines +678 to +679
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this information duplicated in two different files is not ideal. One possible alternative would be to put the list in its own file, and have both posix.mak and betterc_module_tests.d read it in via $(file ...) and string import, respectively, but the extra layer of indirection would make each file harder to read in isolation.

#
# make -f posix.mak betterc-module-tests
################################################################################

BETTERC_MODULES=std/sumtype

betterc: betterc-module-tests

betterc-module-tests: $(ROOT)/betterctests/betterc_module_tests
$(ROOT)/betterctests/betterc_module_tests

$(ROOT)/betterctests/betterc_module_tests: test/betterc_module_tests.d $(addsuffix .d,$(BETTERC_MODULES))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I ought to be re-using this directory from the regular betterC tests or not, but it seems to work.

$(DMD) $(DFLAGS) $(NODEFAULTLIB) -of=$(ROOT)/betterctests/betterc_module_tests -betterC -unittest test/betterc_module_tests.d $(addsuffix .d,$(BETTERC_MODULES))

################################################################################

.PHONY : auto-tester-build
Expand Down
Loading