cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
MIT License
1.06k stars 151 forks source link

`XMLNodeType` declares `~=` infix operator with wrong precedence #119

Open sepw opened 2 years ago

sepw commented 2 years ago

Description:

The ~= infix operator declaration should use the same precedence (ComparisonPrecedence) as Swift's built-in operator.

Node.swift defines the ~= infix operator as follows:

infix operator ~=

This causes the operator to have DefaultPrecedence resulting in the following build error whenever the ~= operator is used with other types in a Swift file that imports Fuzi:

Ambiguous operator declarations found for operator

This can be resolved by re-defining the ~= operator as follows at the point of use:

infix operator ~= : ComparisonPrecedence

However this should not be necessary.

Suggested Solution

Change the operator definition in Node.swift to:

infix operator ~= : ComparisonPrecedence

Environment

How to reproduce:

  1. Open the attached project
  2. Build
  3. Xcode will emit a build error
  4. Comment out operator definition in Sources/FuziTest/FuziTest.swift to fix error.

FuziTest.zip