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

Unable to use as using Match: @match (Match not defined) #68

Closed
Ismael-VC opened this issue Oct 23, 2021 · 3 comments
Closed

Unable to use as using Match: @match (Match not defined) #68

Ismael-VC opened this issue Oct 23, 2021 · 3 comments

Comments

@Ismael-VC
Copy link

Ismael-VC commented Oct 23, 2021

I'm not sure why this happens, maybe it's something to do with macro hygiene?

julia> versioninfo()
Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, haswell)

(@v1.6) pkg> status
      Status `C:\Users\ismae\.julia\environments\v1.6\Project.toml`
  [6e4b80f9] BenchmarkTools v1.2.0
  [c43c736e] Genie v3.2.0
  [7eb4fadd] Match v1.1.0
  [6fe1bfb0] OffsetArrays v1.10.7
  [c3e4b0f8] Pluto v0.16.1
  [b873ce64] ReplMaker v0.2.5
  [98e33af6] SimpleDirectMediaLayer v0.3.0
  [90137ffa] StaticArrays v1.2.13

julia> using Match: @match

julia> @match (0xabcd & 0x1f) begin
           0x0d => :foo
       end
ERROR: UndefVarError: Match not defined
Stacktrace:
 [1] top-level scope
   @ REPL[2]:2

julia> using Match

julia> @match (0xabcd & 0x1f) begin
           0x0d => :foo
       end
:foo
@Ismael-VC Ismael-VC changed the title Unable to use as using Match: @match () Unable to use as using Match: @match (Match not defined) Oct 23, 2021
@kmsquire
Copy link
Contributor

Yeah, the macro itself includes code that calls functions in Match, and therefore requires that Match itself be imported.

This probably isn't fixable here, but the Rematch package works with your example, and has most of the functionality of Match.

I've been planning to merge their package back into Match.jl and transfer the package to them, but haven't gotten around to it.

@kmsquire kmsquire added wontfix and removed wontfix labels Nov 17, 2021
@gafter
Copy link
Member

gafter commented Jul 8, 2023

He's gotten around to it. We're working on it.

@gafter
Copy link
Member

gafter commented Aug 3, 2023

julia> versioninfo()
Julia Version 1.6.6
Commit b8708f954a (2022-03-28 07:17 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Apple M2 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)
Environment:
  JULIA_SSL_CA_ROOTS_PATH = 

(@v1.6) pkg> add Match
  Installing known registries into `~/.julia`
       Added registry `General` to `~/.julia/registries/General`
   Resolving package versions...
    Updating `~/.julia/environments/v1.6/Project.toml`
  [7eb4fadd] + Match v2.0.0
    Updating `~/.julia/environments/v1.6/Manifest.toml`
  [1914dd2f] + MacroTools v0.5.10
  [7eb4fadd] + Match v2.0.0
  [bac558e1] + OrderedCollections v1.6.2
  [2a0f44e3] + Base64
  [d6f4376e] + Markdown
  [9a3f8284] + Random
  [9e88b42a] + Serialization
Precompiling project...
  3 dependencies successfully precompiled in 2 seconds

(@v1.6) pkg> status
      Status `~/.julia/environments/v1.6/Project.toml`
  [7eb4fadd] Match v2.0.0

julia> using Match: @match

julia> @match (0xabcd & 0x1f) begin
                  0x0d => :foo
              end
:foo

@gafter gafter closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants