Opened 13 years ago

Closed 13 years ago

#7967 closed defect (duplicate)

Shrinksafe does not parse legal Javascript correctly

Reported by: lipik Owned by: alex
Priority: high Milestone: tbd
Component: ShrinkSafe Version: 1.2.0
Keywords: Cc:
Blocked By: Blocking:


Here is the schematic of the code that fails for me:

var F = function() {
  var m_a = function() { return m_b() + 1; },
      m_b = function() { return 0; };

  return { fa: m_a, f_b: m_b };

Upon shrinking-safe, the first usage of m_b (that appears before the definition) is not replaced. I imagine it is because the parser is trying to do everything in one pass.

I apologize if there is a "slow but correct" option that I do not know about - I have only just started using ShrinkSafe? as part of dojo build. This issue forced me to rewrite a lot of functions, since I like to use Crockford's private-closures idiom for singleton objects.

Change History (1)

comment:1 Changed 13 years ago by James Burke

Resolution: duplicate
Status: newclosed

Duplicate of #3241. It will probably work if you structure it like so:

var F = function() {
  function m_a() { return m_b() + 1; };
  function m_b() { return 0; };

  return { fa: m_a, f_b: m_b };

Note: See TracTickets for help on using tickets.