Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #174.
The bug was due to
length(default.args) > 1
being used to check whether a constraint was present in the default expression. What should actually be done isdefault.head == :(::)
.Using
length(default.args)
is incorrect because some defaults can have multiple args, such asLikewise, the user might not have used
::
at all to define the constraint.This PR checks for the
::
operator to identify a constraint which fixes this issue.Note that this fix is backwards compatible, so long as people have not been exploiting the bug. See my note at the end of this post for more details.
With this change, we can now do:
whereas before you would get an error due to the incorrectly parsed default, which would parse
0
as the default and1
as the constraint:cc @ablaom
What changes is that a user can no longer exploit the bug. For example, before you actually do:
to give a constraint. Any expression which has the constraint in the second argument would be a valid way of defining this model. Unless you are aware of anybody doing this, I wouldn't worry about it though.
Now if you try to use that syntax, you would get:
which is what we want.