Skip to content

Parsing failure with preocessor expressions #341

Closed
@WillLillis

Description

@WillLillis

After CI failed in #340, I found that a new file had been added to the example set since the last run, which fails to parse. I tried cutting it down to the following minimal example:

#if NETFRAMEWORK
    foo()
#else
#pragma warning disable CS0618
#endif

Parsing output:

(compilation_unit [0, 0] - [5, 0]
  (ERROR [0, 0] - [4, 6]
    (preproc_if [0, 0] - [4, 6]
      condition: (identifier [0, 4] - [0, 16])
      (invocation_expression [1, 4] - [1, 9]
        function: (identifier [1, 4] - [1, 7])
        arguments: (argument_list [1, 7] - [1, 9]))
      alternative: (preproc_else [2, 0] - [2, 5])
      (preproc_pragma [3, 0] - [4, 0]
        (identifier [3, 24] - [3, 30])))))
minimal.cs    0.20 ms         349 bytes/ms (ERROR [0, 0] - [4, 6])

For good measure, here is the relevant section and parsing output for the failed parse of the full file as well:

(ERROR [346, 0] - [352, 6]
  (array_type [346, 4] - [350, 28]
    type: (array_type [346, 4] - [347, 28]
      type: (identifier [346, 4] - [346, 16])
      rank: (array_rank_specifier [347, 12] - [347, 28]
        (invocation_expression [347, 13] - [347, 27]
          function: (identifier [347, 13] - [347, 20])
          arguments: (argument_list [347, 20] - [347, 27]
            (argument [347, 21] - [347, 26]
              (integer_literal [347, 21] - [347, 26]))))))
    (comment [347, 29] - [347, 56])
    (ERROR [348, 0] - [348, 5])
    (preproc_pragma [349, 0] - [350, 0]
      (identifier [349, 24] - [349, 30]))
    rank: (array_rank_specifier [350, 12] - [350, 28]
      (invocation_expression [350, 13] - [350, 27]
        function: (identifier [350, 13] - [350, 20])
        arguments: (argument_list [350, 20] - [350, 27]
          (argument [350, 21] - [350, 26]
            (integer_literal [350, 21] - [350, 26]))))))
  (comment [350, 29] - [350, 56])
  (preproc_pragma [351, 0] - [352, 0]
    (identifier [351, 24] - [351, 30])))
...
#if NETFRAMEWORK
            [Timeout(2_000)] // Ok status will be Passedz
#else
#pragma warning disable CS0618
            [Timeout(2_000)] // Ok status will be Passed
#pragma warning restore CS0618
#endif
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions