Skip to content

Commit

Permalink
Merge branch 'main' into feature/lng-126
Browse files Browse the repository at this point in the history
  • Loading branch information
nahsi authored Nov 22, 2023
2 parents e56afa2 + 3472f20 commit 53ea774
Show file tree
Hide file tree
Showing 141 changed files with 5,038 additions and 2,264 deletions.
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Description
[Provide a brief description of the changes introduced by this pull request and the motivation behind them.]

## Proposed Changes
[List the specific changes and additions introduced by this pull request.]

## Implementation Details
[Provide additional details about the implementation that may be helpful to reviewers.]

## Checklist
- [ ] Corresponding issue has been created and linked in PR title.
- [ ] Proposed changes are covered by tests.
- [ ] Documentation has been updated to reflect the changes (if applicable).
- [ ] I have self-reviewed my code and ensured its quality.
- [ ] I have added/updated necessary comments to aid understanding.

## Reviewer Checklist
- [ ] Tests have been reviewed and are sufficient to validate the changes.
- [ ] Documentation has been reviewed and is up to date.
- [ ] Any questions or concerns have been addressed.

2 changes: 1 addition & 1 deletion .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.12.3"
".": "0.12.4"
}
1 change: 1 addition & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"config:base",
":semanticCommitTypeAll(chore)"
],
"respectLatest": false,
"ignorePaths": ["api/aqua-api-example/**"],
"enabledManagers": ["sbt", "npm", "github-actions"],
"rangeStrategy": "pin",
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ jobs:
with:
ref: ${{ github.ref }}

flox-snapshot:
name: "flox"
fcli-snapshot:
name: "fcli"
needs: aqua
uses: fluencelabs/flox/.github/workflows/snapshot.yml@main
with:
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"

flox:
fcli:
needs: aqua
uses: fluencelabs/fluence-cli/.github/workflows/tests.yml@main
uses: fluencelabs/cli/.github/workflows/tests.yml@main
with:
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"

registry:
needs:
- flox-snapshot
- fcli-snapshot
uses: fluencelabs/registry/.github/workflows/tests.yml@main
with:
flox-version: "${{ needs.flox-snapshot.outputs.version }}"
fcli-version: "${{ needs.fcli-snapshot.outputs.version }}"
10 changes: 5 additions & 5 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ runner {
}
}

rewrite {
rules = [
SortImports
]
}
rewrite.rules = [Imports]
rewrite.imports.sort = ascii
rewrite.imports.groups = [
["aqua\\..*"]
]
#runner.dialect = scala3
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## [0.12.4](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.3...aqua-v0.12.4) (2023-10-23)


### Features

* **compiler:** Handle error function exit in tracing mode [LNG-250] ([#921](https://github.com/fluencelabs/aqua/issues/921)) ([03d23eb](https://github.com/fluencelabs/aqua/commit/03d23eb577d72a3cf592254259aeb9b52b33b616))
* **compiler:** Optimize math in compile time [LNG-245] ([#922](https://github.com/fluencelabs/aqua/issues/922)) ([5f6c47f](https://github.com/fluencelabs/aqua/commit/5f6c47ffea5ab6e32df918a33414482129b00fd7))
* **dev:** Add PR template ([#934](https://github.com/fluencelabs/aqua/issues/934)) ([679d43f](https://github.com/fluencelabs/aqua/commit/679d43f7eb079071ca2a4174f3b8cf5e83d4e16d))


### Bug Fixes

* **compiler:** Fix gate inlining [LNG-253] ([#924](https://github.com/fluencelabs/aqua/issues/924)) ([b298eeb](https://github.com/fluencelabs/aqua/commit/b298eebf5ea1b4c091603ebf0cacde0957191632))
* **compiler:** Fix topology for adjacent `on`s [LNG-257] ([#929](https://github.com/fluencelabs/aqua/issues/929)) ([ba15d9e](https://github.com/fluencelabs/aqua/commit/ba15d9e06afc38f79c95e00d48efbf8937cd251d))
* **compiler:** fix typo ([#916](https://github.com/fluencelabs/aqua/issues/916)) ([feb7a16](https://github.com/fluencelabs/aqua/commit/feb7a167a2007d2c1d75dac6554f36d2cf5f86a5))
* **compiler:** Passed function is not handled correctly [LNG-260] ([#940](https://github.com/fluencelabs/aqua/issues/940)) ([c83d69e](https://github.com/fluencelabs/aqua/commit/c83d69e6895d3784f02c743b89f65606c6302f4b))
* **compiler:** Return ability arrow [LNG-258] ([#935](https://github.com/fluencelabs/aqua/issues/935)) ([fab46ee](https://github.com/fluencelabs/aqua/commit/fab46ee130d4e6b3edd33d0fab4c0f2d27ce5ad0))
* **deps:** update dependency @fluencelabs/js-client to v0.2.1 ([#930](https://github.com/fluencelabs/aqua/issues/930)) ([14f3d92](https://github.com/fluencelabs/aqua/commit/14f3d92ef4cd3fed12cbff0164706b2cbbfdcccd))
* **deps:** update dependency @fluencelabs/js-client to v0.3.0 ([#936](https://github.com/fluencelabs/aqua/issues/936)) ([441c012](https://github.com/fluencelabs/aqua/commit/441c012e01e6e0eff1e1e950b86241982658e80a))

## [0.12.3](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.2...aqua-v0.12.3) (2023-09-28)


Expand Down
2 changes: 2 additions & 0 deletions api/api-npm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type CommonArgs = {
targetType?: "ts" | "js" | "air" | undefined;
/** Compile aqua in tracing mode (for debugging purposes). Default: false */
tracing?: boolean | undefined;
/** Do not generate response call if there are no returned values */
noEmptyResponse?: boolean | undefined;
};

type CodeString = {
Expand Down
2 changes: 2 additions & 0 deletions api/api-npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function getConfig({
noXor = false,
targetType = "air",
tracing = false,
noEmptyResponse = false,
}) {
return new AquaConfig(
logLevel,
Expand All @@ -19,6 +20,7 @@ function getConfig({
air: "air",
}[targetType],
tracing,
noEmptyResponse,
);
}

Expand Down
2 changes: 1 addition & 1 deletion api/api-npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluencelabs/aqua-api",
"version": "0.12.3",
"version": "0.12.4",
"description": "Aqua API",
"type": "module",
"main": "index.js",
Expand Down
9 changes: 6 additions & 3 deletions api/api/.js/src/main/scala/api/types/InputTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import aqua.api.AquaAPIConfig
import aqua.api.TargetType.*
import aqua.js.{FunctionDefJs, ServiceDefJs}
import aqua.model.transform.TransformConfig

import cats.data.Validated.{invalidNec, validNec}
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}

import scala.scalajs.js
import scala.scalajs.js.JSConverters.*
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
Expand Down Expand Up @@ -47,7 +47,9 @@ class AquaConfig(
@JSExport
val targetType: js.UndefOr[String],
@JSExport
val tracing: js.UndefOr[Boolean]
val tracing: js.UndefOr[Boolean],
@JSExport
val noEmptyResponse: js.UndefOr[Boolean]
)

object AquaConfig {
Expand All @@ -69,7 +71,8 @@ object AquaConfig {
constants = cjs.constants.map(_.toList).getOrElse(Nil),
noXor = cjs.noXor.getOrElse(false),
noRelay = cjs.noRelay.getOrElse(false),
tracing = cjs.tracing.getOrElse(false)
tracing = cjs.tracing.getOrElse(false),
noEmptyResponse = cjs.noEmptyResponse.getOrElse(false)
)
}
}
Expand Down
6 changes: 4 additions & 2 deletions api/api/src/main/scala/aqua/api/AquaAPIConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ case class AquaAPIConfig(
constants: List[String] = Nil,
noXor: Boolean = false, // TODO: Remove
noRelay: Boolean = false,
tracing: Boolean = false
tracing: Boolean = false,
noEmptyResponse: Boolean = false
) {

def getTransformConfig: TransformConfig = {
val config = TransformConfig(
tracing = Option.when(tracing)(TransformConfig.TracingConfig.default)
tracing = Option.when(tracing)(TransformConfig.TracingConfig.default),
noEmptyResponse = noEmptyResponse
)

if (noRelay) config.copy(relayVarName = None)
Expand Down
22 changes: 15 additions & 7 deletions aqua-run/src/main/scala/aqua/run/CliFunc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package aqua.run
import aqua.parser.lexer.{CallArrowToken, CollectionToken, LiteralToken, VarToken}
import aqua.parser.lift.Span
import aqua.raw.value.{CollectionRaw, LiteralRaw, ValueRaw, VarRaw}
import aqua.types.{ArrayType, BottomType}
import aqua.types.*

import cats.data.{NonEmptyChain, NonEmptyList, Validated, ValidatedNec}
import cats.data.Validated.{invalid, invalidNec, validNec}
import cats.{~>, Id}
import cats.syntax.traverse.*
import cats.syntax.validated.*
import cats.syntax.either.*
import cats.data.{NonEmptyChain, NonEmptyList, Validated, ValidatedNec}
import cats.syntax.comonad.*
import cats.syntax.either.*
import cats.syntax.option.*
import cats.syntax.traverse.*
import cats.syntax.validated.*
import cats.{Id, ~>}

case class CliFunc(name: String, args: List[ValueRaw] = Nil)

Expand Down Expand Up @@ -52,7 +52,15 @@ object CliFunc {
.map(
NonEmptyList
.fromList(_)
.map(l => CollectionRaw(l, ArrayType(l.head.baseType)))
.map(l =>
CollectionRaw(
l,
ArrayType(
// FIXME: Type of Literal should always be a DataType
l.head.baseType.asInstanceOf[DataType]
)
)
)
.getOrElse(ValueRaw.Nil)
)
.toValidatedNec
Expand Down
6 changes: 2 additions & 4 deletions aqua-run/src/main/scala/aqua/run/TypeValidator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aqua.run

import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw}
import aqua.types.*

import cats.data.Validated.{invalidNec, validNec}
import cats.data.{Validated, ValidatedNec}
import cats.effect.kernel.Async
Expand All @@ -10,14 +11,11 @@ import cats.syntax.flatMap.*
import cats.syntax.partialOrder.*
import cats.syntax.show.*
import cats.syntax.traverse.*

import scala.collection.immutable.SortedMap
import scala.concurrent.ExecutionContext

object TypeValidator {

import aqua.types.Type.typesPartialOrder

/**
* Compare and validate type from Aqua file and type generated from JSON.
* Also, the validation will succeed if the JSON type is missing an array or an optional field.
Expand Down Expand Up @@ -69,7 +67,7 @@ object TypeValidator {
case (l: OptionType, r) =>
// if we have ?[][]string and [][][]string it must throw an error
validateTypes(name, l.element, Some(r), Some((l, r)))
case (l: BoxType, r: BoxType) =>
case (l: CollectionType, r: CollectionType) =>
validateTypes(name, l.element, Some(r.element), fullOptionType.orElse(Some(l, r)))

case (l, r) =>
Expand Down
28 changes: 2 additions & 26 deletions aqua-src/antithesis.aqua
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
aqua M

export getObj

service OpNum("op"):
identity(n: u32) -> u32

service OpStr("op"):
identity(n: string) -> string

service OpArr("op"):
identity(arr: []string) -> []string

data InnerObj:
arr: []string
num: u32

data SomeObj:
str: string
num: u64
inner: InnerObj

func getObj() -> SomeObj:
b = SomeObj(str = OpStr.identity("some str"), num = 5, inner = InnerObj(arr = ["a", "b", "c"], num = 6))
c = b.copy(str = "new str", inner = b.inner.copy(num = 3))
<- c
func arr(strs: []string) -> []string
<- strs
4 changes: 2 additions & 2 deletions backend/air/src/main/scala/aqua/backend/air/Air.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object Air {
iterable: DataView,
label: String,
instruction: Air,
lastNextInstruction: Option[Air]
lastNextInstruction: Air
) extends Air(Keyword.Fold)

case class Match(left: DataView, right: DataView, instruction: Air) extends Air(Keyword.Match)
Expand Down Expand Up @@ -137,7 +137,7 @@ object Air {
case Air.Next(label) s" $label"
case Air.New(item, inst) s" ${item.show}\n${showNext(inst)}$space"
case Air.Fold(iter, label, inst, lastInst)
val l = lastInst.map(a => show(depth + 1, a)).getOrElse("")
val l = show(depth + 1, lastInst)
s" ${iter.show} $label\n${showNext(inst)}$l$space"
case Air.Match(left, right, inst)
s" ${left.show} ${right.show}\n${showNext(inst)}$space"
Expand Down
11 changes: 5 additions & 6 deletions backend/air/src/main/scala/aqua/backend/air/AirGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ object AirGen extends Logging {
)

case FoldRes(item, iterable, mode) =>
val m = mode.map {
case ForModel.Mode.Null => NullGen
case ForModel.Mode.Never => NeverGen
val m = mode match {
case FoldRes.Mode.Null => NullGen
case FoldRes.Mode.Never => NeverGen
}
Eval later ForGen(valueToData(iterable), item, opsToSingle(ops), m)
case RestrictionRes(item, itemType) =>
Expand Down Expand Up @@ -202,9 +202,8 @@ case class MatchMismatchGen(
else Air.Mismatch(left, right, body.generate)
}

case class ForGen(iterable: DataView, item: String, body: AirGen, mode: Option[AirGen])
extends AirGen {
override def generate: Air = Air.Fold(iterable, item, body.generate, mode.map(_.generate))
case class ForGen(iterable: DataView, item: String, body: AirGen, mode: AirGen) extends AirGen {
override def generate: Air = Air.Fold(iterable, item, body.generate, mode.generate)
}

case class NewGen(name: String, body: AirGen) extends AirGen {
Expand Down
Loading

0 comments on commit 53ea774

Please sign in to comment.