-
Notifications
You must be signed in to change notification settings - Fork 42
Bugfix if-feature validate status and in enum or bits as default value notchecked #26
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
Open
fredgan
wants to merge
1
commit into
mbj4668:master
Choose a base branch
from
fredgan:bugfix-if-feature-in-enum-bits-defaultvalue-notchecked
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| module enum-bit-default { | ||
| yang-version 1.1; | ||
| namespace urn:enum-bit-default; | ||
| prefix ebd; | ||
|
|
||
| feature foo; | ||
| feature bar; | ||
| feature baz; | ||
|
|
||
| typedef myEnum { | ||
| type enumeration { | ||
| enum foo { | ||
| if-feature "foo"; | ||
| } | ||
| enum bar { | ||
| if-feature "not bar"; | ||
| } | ||
| enum baz; | ||
| } | ||
| } | ||
|
|
||
| typedef myBits { | ||
| type bits { | ||
| bit foo { | ||
| if-feature "foo"; | ||
| } | ||
| bit bar { | ||
| if-feature "not bar"; | ||
| } | ||
| bit baz; | ||
| } | ||
| } | ||
|
|
||
| leaf enum0 { | ||
| type myEnum; | ||
| default "no"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf enum1 { | ||
| type myEnum; | ||
| default "foo"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf enum2 { | ||
| type myEnum; | ||
| default "bar"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf enum3 { | ||
| type myEnum; | ||
| default "baz"; | ||
| } | ||
|
|
||
| leaf bit0 { | ||
| type myBits; | ||
| default "no"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit1 { | ||
| type myBits; | ||
| default "foo"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit2 { | ||
| type myBits; | ||
| default "bar"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit3 { | ||
| type myBits; | ||
| default "baz"; | ||
| } | ||
|
|
||
| leaf bit4 { | ||
| type myBits; | ||
| default "no foo"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit5 { | ||
| type myBits; | ||
| default "foo no"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit6 { | ||
| type myBits; | ||
| default "no baz"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit7 { | ||
| type myBits; | ||
| default "baz no"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit8 { | ||
| type myBits; | ||
| default "foo bar baz"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
|
|
||
| leaf bit9 { | ||
| type myBits; | ||
| default "baz bar foo"; // LINE: YANG_ERR_TYPE_VALUE | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| module feat-status { | ||
| yang-version 1.1; | ||
| namespace urn:feat-status; | ||
| prefix fs; | ||
|
|
||
| feature f; | ||
|
|
||
| feature f1 { | ||
| status obsolete; | ||
| } | ||
|
|
||
| feature f2 { | ||
| if-feature "f"; | ||
| } | ||
|
|
||
| feature f3 { | ||
| if-feature "no"; // LINE: YANG_ERR_DEFINITION_NOT_FOUND | ||
| } | ||
|
|
||
| feature f4 { | ||
| if-feature "fs:f1"; // LINE: YANG_BAD_STATUS_REFERENCE | ||
| } | ||
|
|
||
| feature f5 { | ||
| if-feature "not fs:f1 or f"; // LINE: YANG_BAD_STATUS_REFERENCE | ||
| } | ||
|
|
||
| feature f6 { | ||
| status deprecated; | ||
| if-feature f1; // LINE: YANG_BAD_STATUS_REFERENCE | ||
| } | ||
|
|
||
| leaf l { | ||
| type empty; | ||
| if-feature "f"; | ||
| } | ||
|
|
||
| leaf l2 { | ||
| type empty; | ||
| if-feature "no"; // LINE: YANG_ERR_DEFINITION_NOT_FOUND | ||
| } | ||
|
|
||
| leaf l3 { | ||
| type empty; | ||
| if-feature "f1"; // LINE: YANG_BAD_STATUS_REFERENCE | ||
| } | ||
|
|
||
| container c { | ||
| if-feature "f1"; // LINE: YANG_BAD_STATUS_REFERENCE | ||
| leaf l3 { | ||
| type empty; | ||
| } | ||
| } | ||
| } |
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.
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.
I think that this is not the right place to do this test - this function parses a string into an enum. In this module it is only used to parse default values, which is why this works. But the function is more generic than that - it isn't called "{parse_default_value", just "{parse". It is also exported which means that it is part of the API.
Instead, I think the right place is in "derive". The check must be different; you need to check if a default statement is present in the TypeS, and if so, find the corresponing enum statement and report an error if it has a if-feature statement.
Ditto for bits.
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.
I do this test according to the current logic - "Val" which is a default value is used to check whether the default value is defined, I just add a check about the default value without a
if-featurestatement, so I think this may be the right position.Follow as your tips, I reread the code about parsing the types of enumeration/bits, then debug it. If this test is placed in "derive" here,
yanger/src/yang_types.erl
Lines 675 to 682 in 8adf023
the default value, of course, I am not sure that I exactly understand what you mean.