Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Conversation

tjprescott
Copy link
Owner

No description provided.

Comment on lines 57 to 58
case .unresolved:
fatalError("Unable to get Swift value from unresolved node type.")
Copy link
Owner Author

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.

Comment on lines +33 to +45
/// 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
}
Copy link
Owner Author

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)
Copy link

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
Copy link

@sacheu sacheu Sep 10, 2020

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.
Copy link

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.
Copy link

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`.
Copy link

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 {
Copy link

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

@tjprescott tjprescott closed this Oct 26, 2022
@tjprescott tjprescott deleted the CircularReferences branch October 26, 2022 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants