diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt index 416329e..286ca63 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -324,15 +324,14 @@ private class Parser(fromPos: Pos) { } '?' -> { - when (currentChar.also { pos.advance() }) { - ':' -> Token("??", from, Token.Type.ELVIS) - '?' -> Token("??", from, Token.Type.ELVIS) - '.' -> Token("?.", from, Token.Type.NULL_COALESCE) - '[' -> Token("?(", from, Token.Type.NULL_COALESCE_INDEX) - '(' -> Token("?(", from, Token.Type.NULL_COALESCE_INVOKE) - '{' -> Token("?{", from, Token.Type.NULL_COALESCE_BLOCKINVOKE) + when (currentChar) { + ':' -> { pos.advance(); Token("?:", from, Token.Type.ELVIS) } + '?' -> { pos.advance(); Token("??", from, Token.Type.ELVIS) } + '.' -> { pos.advance(); Token("?.", from, Token.Type.NULL_COALESCE) } + '[' -> { pos.advance(); Token("?[", from, Token.Type.NULL_COALESCE_INDEX) } + '(' -> { pos.advance(); Token("?(", from, Token.Type.NULL_COALESCE_INVOKE) } + '{' -> { pos.advance(); Token("?{", from, Token.Type.NULL_COALESCE_BLOCKINVOKE) } else -> { - pos.back() Token("?", from, Token.Type.QUESTION) } } diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt index a1cc586..cf89fed 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -149,6 +149,8 @@ open class Obj { // methods that to override open suspend fun compareTo(scope: Scope, other: Obj): Int { + if( other === this) return 0 + if( other === ObjNull ) return 2 scope.raiseNotImplemented() }