-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix circular references issue #1
Conversation
Sources/Yams/Constructor.swift
Outdated
case .unresolved: | ||
fatalError("Unable to get Swift value from unresolved node type.") |
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.
This is what I'm troubleshooting now. Once this is fixed, I should be able to make a PR against YAMS.
/// The plain scalar style. | ||
case plain | ||
|
||
/// The single-quoted scalar style. | ||
case singleQuoted | ||
/// The double-quoted scalar style. | ||
case doubleQuoted | ||
|
||
/// The literal scalar style. | ||
case literal | ||
/// The folded scalar style. | ||
case folded | ||
} |
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.
This is literally copy-paste from Node.Scalar
so it may not be necessary.
} | ||
|
||
func loadNode(from event: Event) throws -> Node { | ||
switch event.type { | ||
case YAML_ALIAS_EVENT: | ||
return try loadAlias(from: event) | ||
do { | ||
return try loadAlias(from: event) |
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.
can we change the loadAlias
to do return Node(unresolved: alias, error: yamlError)
when an alias is not found in anchor array? instead of throw an exception in loadAlias and then catch it in loadNode and return Node(unresolved: alias, error: yamlError)
/// This node's tag (its type). | ||
public var tag: Tag | ||
/// The style to be used when emitting this node. | ||
public var style: Style |
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.
Do we need 'style' for Node.Unresolved'? I think we can try removing 'style' and also the Style enum.
/// Create a `Node.scalar` with a string, tag & scalar style. | ||
/// | ||
/// - parameter alias: Alias value for this node. | ||
/// - parameter tag: Tag for this node. |
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.
miss YamlError in the doc
@@ -45,6 +47,49 @@ extension Node { | |||
public init(_ nodes: [Node], _ tag: Tag = .implicit, _ style: Sequence.Style = .any) { | |||
self = .sequence(.init(nodes, tag, style)) | |||
} | |||
|
|||
/// Create a `Node.scalar` with a string, tag & scalar style. |
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.
Should be Node.Unresolved
} | ||
} | ||
|
||
/// Get or set the `Node.Unresolved` value if this node is a `Node.undefined`. |
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.
what is 'Node.undefined' in this context?
case let .mapping(mapping): | ||
var map = [(Node, Node)]() | ||
var iterator = mapping.makeIterator() | ||
while true { |
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 suggest to remove the while true loop
No description provided.