-
Notifications
You must be signed in to change notification settings - Fork 24
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(compiler): Use strict
to check types availability [LNG-334]
#1071
Conversation
strict
to check types availabilitystrict
to check types availability
strict
to check types availabilitystrict
to check types availability [LNG-334]
language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala
Outdated
Show resolved
Hide resolved
language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala
Outdated
Show resolved
Hide resolved
semantics/src/main/scala/aqua/semantics/expr/func/ArrowSem.scala
Outdated
Show resolved
Hide resolved
@@ -14,7 +14,7 @@ import cats.syntax.validated.* | |||
|
|||
final case class TypeResolution[S[_], +T]( | |||
`type`: T, | |||
definitions: List[(Token[S], NamedTypeToken[S])] | |||
definitions: List[(Token[S], String)] |
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.
After change, those are not definitions
, but occurrences
rather.
I am scared by amount of (Token[S], String)
in the code. Maybe create a class for that already?
@@ -99,7 +99,7 @@ class ValuesAlgebra[S[_], Alg[_]: Monad](using | |||
case None => | |||
(for { | |||
t <- OptionT( | |||
T.getType(name.value) | |||
T.getType(name.value, name) |
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.
We could accept NamedTypeToken[S]
in getType
. Name[S]
have method asTypeToken
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.
Also getType
does exactly the same as resolveType
, except that resolveType
might report an error. In NamesAlgebra
in similar situation we added a boolean flag to control error reporting. Maybe do the same here and remove getType
method?
|
||
override def resolveType(token: TypeToken[S]): State[X, Option[Type]] = | ||
getState.map(TypeResolution.resolveTypeToken(token)).flatMap { | ||
case Valid(TypeResolution(typ, tokens)) => | ||
val tokensLocs = tokens.map { case (t, n) => n.value -> t } | ||
val tokensLocs = tokens.map { case (t, n) => n -> t } |
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.
Maybe return them in this order inside TypeResolution
?
@@ -720,7 +722,7 @@ class TypesInterpreter[S[_], X](using | |||
)( | |||
ifNotDefined: => State[X, A] | |||
): State[X, A] = getState | |||
.map(_.definitions.get(name)) | |||
.map(_.strict.get(name)) |
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.
.map(_.strict.get(name)) | |
.map(_.getType(name)) |
@@ -180,8 +182,7 @@ class TypesInterpreter[S[_], X](using | |||
) | |||
|
|||
override def defineAlias(name: NamedTypeToken[S], target: Type): State[X, Boolean] = | |||
getState.map(_.definitions.get(name.value)).flatMap { | |||
case Some(n) if n == name => State.pure(false) | |||
getState.map(_.strict.get(name.value)).flatMap { |
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.
getState.map(_.strict.get(name.value)).flatMap { | |
getState.map(_.getType(name.value)).flatMap { |
override def getType(name: String): State[X, Option[Type]] = | ||
getState.map(st => st.strict.get(name)) | ||
override def getType(name: String, token: Token[S]): State[X, Option[Type]] = | ||
OptionT(getState.map(st => st.strict.get(name))) |
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.
OptionT(getState.map(st => st.strict.get(name))) | |
OptionT(getState.map(st => st.getType(name))) |
language-server/language-server-api/src/main/scala/aqua/lsp/LocationsInterpreter.scala
Outdated
Show resolved
Hide resolved
…cationsInterpreter.scala Co-authored-by: InversionSpaces <[email protected]>
Description
Use
strict
to prevent registering types when there is types with the same name imported from another file.Also, fix token locations for services, abilities and structures.
fixes LNG-334
fixes LNG-335
fixes LNG-336
fixes LNG-299
fixes LNG-300
Checklist
Reviewer Checklist