inkytonik / cooma

The Cooma project is investigating secure programming language design based on fine-grained object capabilities.
Mozilla Public License 2.0
3 stars 2 forks source link

Fix expected types for type applications #4

Closed inkytonik closed 3 years ago

inkytonik commented 3 years ago

Currently is not checking all of these since expected type is None in some cases

Need to propogate types through similar to in appType Can share code?

See stash wip type app expected arg type has a test that fails at present (commented out)

Also need this test for equal:

        SemanticTest(
            s"Wrong argument type for equal",
            s"""equal(Int, 1, \"2\")""",
            s"""|1:15:error: expected Int, got "2" of type String
                |equal(Int, 1, "2")
                |              ^
                |"""
        ),

also add one for structured values (two records of different type, two variants of different type)

Add more tests:

Currently just have the id function

Works for defs?

Use some to write type constructor functions?

Multiple type params in one function

Nested use of type param ie a type param bound at one level and used somewhere inner that isn’t the same arg list as the place where the type param is bound this one would require specialisation of the applied function expression as well as its type

inkytonik commented 3 years ago

Update primitive tests such as VecAppend(1, 1, 1) to check the later arguments. E.g.,

             SemanticTest(
                s"Wrong argument type for VecAppend primitive (vector 1)",
                s"""prim VecAppend(Int, 1, 1)""",
                s"""|1:21:error: expected Vector(Int), got 1 of type Int
                    |prim VecAppend(Int, 1, 1)
                    |                    ^
                    |"""
            ),
inkytonik commented 3 years ago

Make sure that this check gets put back in to checkInput in REPL.scala:

        case (Vector(), _, _, None) =>
               sys.error(s"checkInput: couldn't find aliased REPL type for $input")

For now we are ignoring this in the REPL since it triggers spurious errors when we test some vector primitives.

Will also need to add types to the Vector REPL tests since for now we get no type in that situation.