Giter Club home page Giter Club logo

Comments (4)

shonfeder avatar shonfeder commented on July 1, 2024

We have a test for this, so I'm not sure how this is arising in the integration test yet:

test("Open Quint record types are converted into open TlaType1 records") {
val record =
// i.e.: { f1: int, f2: string | r }
QuintRecordT(Row.Cell(List(RecordField("f1", QuintIntT()), RecordField("f2", QuintStrT())), Row.Var("r")))
assert(Quint.typeToTlaType(record) == RecRowT1(RowT1(VarT1(0), ("f1" -> IntT1), ("f2" -> StrT1))))
}

from apalache.

shonfeder avatar shonfeder commented on July 1, 2024

7ac4e54 adds the support for row-typed records we need to properly type quint records, but the type checking guards in the builder are not hip to row types, so I'm now getting

      > Name updateF1 with type (({ f1: Int }) => { f1: Int }) constructed in scope where expected type is (({ f1: Int, f2: Str, a }) => { f1: Int, f2: Str, a }). E@18:16:20.594

from apalache.

shonfeder avatar shonfeder commented on July 1, 2024

Ah, the row typing is getting lost on the quint side actually:

Given

    def updateF1(r) = r.with("f1", 1) 

    action Next = all {
        rec1' = updateF1(rec1),
        rec2' = rec2.with("f3", true),
        rec3' = updateF1(rec3),
    }

The source map for the declaration of updateF1 looks like:

{
          "id": 20,
          "kind": "def",
          "name": "updateF1",
          "qualifier": "def",
          "expr": {
            "id": 20,
            "kind": "lambda",
            "params": [{ "id": 15, "name": "r" }],
            "qualifier": "def",
            "expr": {
              "id": 19,
              "kind": "app",
              "opcode": "with",
              "args": [
                { "id": 16, "kind": "name", "name": "r" },
                { "id": 17, "kind": "str", "value": "f1" },
                { "id": 18, "kind": "int", "value": 1 }
              ]
            }
          }
        }

But the source map we get for the application of updateF1 looks like this:

                  {
                    "id": 43,
                    "kind": "app",
                    "opcode": "updateF1",
                    "args": [{ "id": 42, "kind": "name", "name": "rec1" }]
                  }

When we then construct the application of updateF1, we need to supply the type for the operator updateF1 to the builder, but we we deduce this its application context alone, which doesn't give us access to the type of the operator at time of declaration. Instead we only have this to work with:

    "43": {
      "typeVariables": {},
      "rowVariables": {},
      "type": {
        "kind": "rec",
        "fields": {
          "kind": "row",
          "fields": [{ "fieldName": "f1", "fieldType": { "kind": "int" } }],
          "other": {
            "kind": "row",
            "fields": [
              { "fieldName": "f2", "fieldType": { "id": 2, "kind": "str" } }
            ],
            "other": { "kind": "var", "name": "r1" }
          }
        }
      }
    },

Since the "scope safe" builder is policing consistent typing of named expressions, once a closed type has been inferred for the operator application, subsequent applications licensed by the polymorphic type of the declared operator, instead are rejected due to the conflict of the
concrete types.

Options:

  • Use the builder that doesn't enforce singular typing of names.
  • Extend the context of the converter to track the type of declared operator by name.
  • Extend the QuintIR so it includes the ID of a name's definition along with each occurence of the name

from apalache.

shonfeder avatar shonfeder commented on July 1, 2024

@gabrielamafra noted that we're not using the lookup table currently, support for exporting this was just added recently, but it will give us a way to derive the type of the defined operator. 🎉

from apalache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.