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

-O2 causes colon Hash syntax to become a Pair(Hash, key) inside classes #84

Closed
catb0t opened this issue Mar 8, 2019 · 0 comments
Closed

Comments

@catb0t
Copy link
Contributor

catb0t commented Mar 8, 2019

class X {
  has Hash colon_inner = Hash(
    :prop => :(:k => :v)
  )

  has Hash colon_outer = :(
    :prop => Hash(:k => :v)
  )

  has Hash colon_both = :(
    :prop => :(:k, :v)
  )

  has Hash colon_none = Hash(
    :prop => Hash(:k, :v)
  )

}

func g {
  var Hash y = :(:k, :())
  say "y:\t#{y}"
}

var x = X()
say "inner:  #{x.colon_inner}"
say "outer:  #{x.colon_outer}"
say "both:   #{x.colon_both}"
say "none:   #{x.colon_none}"

var Hash h = :(:k => :())

say "h: \t#{h}"

g()

say x.colon_outer\{:prop}

With -O2

inner:  Hash("prop" => Pair(Sidef::Types::Hash::Hash, "k"))
outer:  Pair(Sidef::Types::Hash::Hash, "prop")
both:   Pair(Sidef::Types::Hash::Hash, "prop")
none:   Hash("prop" => Hash("k" => "v"))
h: 	Hash("k" => Hash())
y:	Hash("k" => Hash())
Not a HASH reference at (eval 5) line 5.

with -O1 or -O0

inner:  Hash("prop" => Hash("k" => "v"))
outer:  Hash("prop" => Hash("k" => "v"))
both:   Hash("prop" => Hash("k" => "v"))
none:   Hash("prop" => Hash("k" => "v"))
h: 	Hash("k" => Hash())
y:	Hash("k" => Hash())
Hash("k" => "v")

This is another bug I was seeing when I was reporting #79, but I can't reproduce it on -O0 anymore. Hopefully, I'm misremembering and it's not actually possible to see with -O0.

I don't know why this happens anyway? Does Hash.: get MRO'd in the wrong order (Object before Hash) with the Optimizer?

@trizen trizen closed this as completed in 9244cf4 Mar 8, 2019
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

1 participant