Skip to content

omgidl-parser : Infinity / NaN value not resolved in IDL definition #300

@paulsohn

Description

@paulsohn

Description
Infinity / NaN default value not resolved in IDL definition

  • Version: 1.1.0 (likely in 1.2.0)
  • Platform: Web(V8) / node.js v22.15.0 via Jest

Steps To Reproduce

import { parseIDL } from "@foxglove/omgidl-parser";

const x = parseIDL(`module test_msgs {
  module msg {
    struct Test {
      @default (value=NaN)
      float foo;
    };
  };
};`);
console.log(x);

This throws the following error:

Could not find node NaN in test_msgs::msg::Test referenced by test_msgs::msg::Test::foo

Expected Behavior
Parse succesfully and not throwing error.

For reference, if I quote NaN to "NaN", then it parses and logs the following array:

[
    {
        "name": "test_msgs::msg::Test",
        "definitions": [
            {
                "name": "foo",
                "type": "float32",
                "isComplex": false,
                "annotations": {
                    "default": {
                        "type": "named-params",
                        "name": "default",
                        "namedParams": {
                            "value": "NaN"
                        }
                    }
                },
                "defaultValue": "NaN"
            }
        ],
        "aggregatedKind": "struct"
    }
]

This also parses correctly if the default value is normal number literal, e.g. 1.0. But not Infinity and NaN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions