We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8de2803 commit d1a2786Copy full SHA for d1a2786
1 file changed
pkg/lang/keyword.go
@@ -101,7 +101,27 @@ func (k Keyword) Hash() uint32 {
101
102
func (k Keyword) Compare(other any) int {
103
if otherKw, ok := other.(Keyword); ok {
104
- return strings.Compare(k.String(), otherKw.String())
+ s := k.String()
105
+ os := otherKw.String()
106
+ if s == os {
107
+ return 0
108
+ }
109
+ ns := k.Namespace()
110
+ if ns == "" {
111
+ if otherKw.Namespace() != "" {
112
+ return -1
113
114
+ } else {
115
+ ons := otherKw.Namespace()
116
+ if ons == "" {
117
+ return 1
118
119
+ nsc := strings.Compare(ns, ons)
120
+ if nsc != 0 {
121
+ return nsc
122
123
124
+ return strings.Compare(k.Name(), otherKw.Name())
125
}
126
panic(NewIllegalArgumentError(fmt.Sprintf("Cannot compare Keyword with %T", other)))
127
0 commit comments