First off, thanks for your interest in contributing !
We exclusively use bugzilla for issue tracking, which is why Github issues are disabled on this repository. If you found a bug, please check bugzilla to see if it's already reported. If it isn't, you can create a new issue.
If you have question about a specific behavior, the D.Learn group is a good place to ask for clarification before reporting an issue.
When creating a new issue, make sure to include:
- which version of DMD you are using (which can be found by running
dmd
with no argument). - A test case:
- Make it a short, self contained and compilable example.
- Avoid dependencies to foreign code (e.g. dub packages).
- Avoid any imports from phobos / druntime if possible. You can try minimizing your test case using the DustMite tool. DustMite is also available from our tools repository and is distributed with DMD.
When finding a regression, please label the issue as such:
- Set the field 'Severity' to 'Regression' (highest level of priority)
- Prefix the issue title with
[REG 2.XXX.Y]
where2.XXX.Y
is the first broken version whenever possible.
To help track down the point where regressions were introduced down, you can use the excellent Digger tool. Digger will automatically bisect the history for you.
We use bugzilla to list fixed issues on a new release. This list is then included in the changelog. For this list to be accurate then invalid or duplicated bugs must be closed with the appropriate resolution ('RESOLVED INVALID' and 'RESOLVED DUPLICATE', respectively - as opposed to e.g. 'RESOLVED FIXED').
Before submitting a PR there are some things you can check which will hopefully make the pulling process run smoothly.
-
Make sure to target the right branch. Regressions go to stable, and everything else to master, as outlined in our release process.
-
When fixing a bugzilla issue, use the title : 'Fix issue XXXXX - Issue title'. This is recognized by both bugzilla and our github bot (dlang-bot), and will automatically link the issue and the pull request together (by providing a link to the issue in Github, and automatically closing bugs when pull requests are merged).
-
Document the 'why' (the change is necessary and was done this way) rather than the 'how'.
-
Ensure newly introduced symbols are documented and that updates to existing symbols are reflected in the documentation.
-
Add a link to the PR to the bugzilla entry.
-
If your pull request affects the language specifications in any way (i.e. changing the grammar, deprecating a feature or adding a new one), a pull request to the website should be submitted in parallel.
-
Follow the usual git good practice:
- Provide descriptive commit messages
- Avoid changes not relevant to the issue (i.e. style issues)
- Separate commit for separate concerns
- Keep pull requests focused on one single topic or bug. For example, if your fix requires a refactoring, then the refactoring should be submitted as a separate pull request.
For first-time contributers, we suggest to look for issues categorized as trivial. You may continue with issues categorized bootcamp.
If you want a hassle-free contribution look for issues categorized as preapproved.
Here is a short list of stylistic issues the core team will expect in pull requests. Much of the source code does not follow these, but we expect new code to, and PRs retrofitting the existing code to follow it is welcome.
-
Use attributes
const
/nothrow
/pure
/scope
/@safe
/private
/etc. Successfully usingpure
functions is regarded with particular favor. -
Use correct Ddoc function comment blocks. Do not use Ddoc comments for overrides unless the overriding function does something different (as far as the caller is concerned) than the overridden function. Ddoc comment blocks are often overkill for nested functions and function literals; use ordinary comments for those. Follow the D Style for comment blocks.
-
Do not use
strlen
/strcmp
and their ilk. Use D arrays instead. If slicing from achar*
is required then usedmd.utils.toDString
or the member function.toString
that is implemented in many classes. -
Use
ref
/out
instead of raw pointers. -
Use nested functions to get rid of rats' nests of goto's.
-
Look for duplicative code and factor out into functions.
-
Declare local variables as
const
as much as possible. -
Use Single Assignment for local variables:
T t = x;
...
t = y;
...
becomes:
T tx = x;
...
T ty = y;
...
-
"Shrinkwrap" the scope of local variables as tightly as possible around their uses.
-
Similar to (8), use distinct variable names for non-overlapping uses.
-
Avoid use of mutable globals as much as practical. Consider passing them in as parameters.
-
Avoid use of default parameters. Spell them out.
-
Minimize use of overloading.
-
Avoid clever code. Anybody can write clever code. It takes genius to write simple code.
-
Try to reduce cyclomatic complexity, i.e. think about how to make the code work without control flow statements.
-
Try not to mix functions that "answer a question" with functions that "mutate the data". This was done successfully in src/dmd/escape.d, it wasn't easy, but it was well worth it.
-
Try to eliminate reliance on
global.errors
. -
For aggregates that expose public access to fields, think hard about why this is necessary and if it can be done better. Merely replacing them with read/write properties accomplishes nothing. The more of its internal details can be made private, the better.
-
Try to use function prefixes:
is
is the parameter in a certain category?has
does the parameter have a certain feature?can
for can I do X with the parameter?
Such functions should not be mutating the data nor issuing error messages.
-
The function return value variable should be named
result
. -
The more constrained the scope of a name is, the shorter it should be.
-
Shuffling all the code about
-
As a general rule, any improvement that is implemented by using sed scripts across the source tree is likely to be disruptive and unlikely to provide significant improvement.
-
Reformatting into your personal style. Please stick with the existing style. Use the D Style for new code.
As always, treating the above as sacred writ is a huge mistake. Use your best judgement on a case-by-case basis. Blindly doing things just adds more technical debt.
For questions and discussions related to DMD development, a mailing list is available.