Skip to content

Unquoted matches are not available in the same pattern #473

Open

Description

@usaoc

Unquoted matches, that is, $ matches in a '' pattern, are not available within that pattern, even to later subpatterns. For example,

#lang rhombus/static
'1 2' is_a matching(
  '$(first_int :: Int)
     $(pattern:
         kind ~term
       | '$(second_int :: Int)':
           match_when first_int.unwrap() == second_int.unwrap())'
)

this program does not work, nor does

#lang rhombus/static
syntax_class SomeInt(int):
  kind ~term
| '$(this_int :: Int)':
    match_when this_int.unwrap() == int

'1 2' is_a matching(
  '$(first_int :: Int)
     $(_ :: SomeInt(first_int.unwrap()))'
)

In contrast, the corresponding Racket program

#lang racket/base
(require syntax/parse)

(syntax-parse #'(1 2)
  [(first-int:integer
    (~and second-int:integer
          (~fail #:unless (eqv? (syntax-e #'first-int)
                                (syntax-e #'second-int)))))
   #t]
  [_ #f])

works just fine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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