Clojure

Redefining a function that uses a redifined macro, picks up old macro defintion

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

Redefining a function to use an updated macro definition fails to work correctly, with the function still using the previous macro definiton. This seems to be a regression.

Test case: http://gist.github.com/420007
Bisection : http://gist.github.com/420075

Activity

Hide
Assembla Importer added a comment -

cgrand said: This bug is caused by top-level fns not being numbered anymore. Since their name doesn't change, the classCache in DynamicClassLoader finds the previous defintion, compares the expressions bodies (before macroexpansion) and thus concludes the cache entry is fresh and returns it.

I see two potential fixes:

  • use a deeply macroexpanded body as the value of the cache entry, but this would require building this body – however it isn't enough, see http://gist.github.com/420344: hinting doesn't change value since it's metadata so the unhinted version keeps getting pulled from the cache. This is not an acceptable fix.
  • use (wrapped) byte arrays as values (eg java.nio.ByteBuffer/wrap creates wrappers with value-based equality) but I don't know under which conditions a reload would produce two identical byte arrays – experimentally, types and records Classes are pulled from the cache when reloaded but fns aren't.
Show
Assembla Importer added a comment - cgrand said: This bug is caused by top-level fns not being numbered anymore. Since their name doesn't change, the classCache in DynamicClassLoader finds the previous defintion, compares the expressions bodies (before macroexpansion) and thus concludes the cache entry is fresh and returns it. I see two potential fixes:
  • use a deeply macroexpanded body as the value of the cache entry, but this would require building this body – however it isn't enough, see http://gist.github.com/420344: hinting doesn't change value since it's metadata so the unhinted version keeps getting pulled from the cache. This is not an acceptable fix.
  • use (wrapped) byte arrays as values (eg java.nio.ByteBuffer/wrap creates wrappers with value-based equality) but I don't know under which conditions a reload would produce two identical byte arrays – experimentally, types and records Classes are pulled from the cache when reloaded but fns aren't.
Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - stu said: [file:aLXklKBE8r36weeJe5cbLA]
Hide
Assembla Importer added a comment -

stu said: This issue was already fixed by http://github.com/richhickey/clojure/commit/f47b3d6f028e0370c495383731a449092d0ae451, but I wanted to add a regression test.

Also: the file this regression test lives in is not in the test suite list yet – I already have a commit fixing that queued up as part of #359.

Show
Assembla Importer added a comment - stu said: This issue was already fixed by http://github.com/richhickey/clojure/commit/f47b3d6f028e0370c495383731a449092d0ae451, but I wanted to add a regression test. Also: the file this regression test lives in is not in the test suite list yet – I already have a commit fixing that queued up as part of #359.
Hide
Assembla Importer added a comment -

stu said: Patch is just a regression test for fix already made.

Show
Assembla Importer added a comment - stu said: Patch is just a regression test for fix already made.
Hide
Assembla Importer added a comment -

stu said: Updating tickets (#139, #278, #285, #368, #443, #430)

Show
Assembla Importer added a comment - stu said: Updating tickets (#139, #278, #285, #368, #443, #430)
Hide
Assembla Importer added a comment -

stu said: Updating tickets (#139, #278, #285, #368, #443, #430)

Show
Assembla Importer added a comment - stu said: Updating tickets (#139, #278, #285, #368, #443, #430)

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: