Skip to content
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

Invalid constants can pass validation #1091

Closed
mark-koch opened this issue May 21, 2024 · 2 comments
Closed

Invalid constants can pass validation #1091

mark-koch opened this issue May 21, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mark-koch
Copy link
Contributor

The following Hugr validates, even though { "c": "ConstF64", "v": 42 } is an incorrect serialisation of float values (it should be { "c": "ConstF64", "v": { "value": 42.0 } } instead):

{
   "version": "v1",
   "nodes": [
      {
         "parent": 0,
         "input_extensions": null,
         "op": "Const",
         "v": {
            "v": "Extension",
            "extensions": [
               "arithmetic.float.types"
            ],
            "typ": {
               "t": "Opaque",
               "extension": "arithmetic.float.types",
               "id": "float64",
               "args": [],
               "bound": "C"
            },
            "value": {
               "c": "ConstF64",
               "v": 42
            }
         }
      }
   ],
   "edges": [],
   "encoder": null
}

@doug-q doug-q self-assigned this May 21, 2024
@ss2165 ss2165 added the bug Something isn't working label Jun 18, 2024
@doug-q
Copy link
Collaborator

doug-q commented Jun 19, 2024

I think this bug comes from OpaqueValue treating these two cases as the same:

  • can't deserialize because it's an unknown CustomConst
  • a known CustomConst failed to deserialize

when they should be treated differently. The first case is fine, leave a CustomSerialized in the Hugr. The second case should result in a deserialization failure.

If that is true then this is distinct from #1185, which is about validation not happening at all.

@ss2165
Copy link
Member

ss2165 commented Jul 3, 2024

Remaining parts of this covered by #1225

@ss2165 ss2165 closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants