• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/99_bugs/55_strict_undeclared_assignment

  1 In strict mode, assigning to an undeclared variable raised the expected
  2 reference error but still performed the assignment, so the variable came
  3 into existence when the exception was caught. Ensure the assignment and
  4 compound update are suppressed when the exception is raised.
  5 
  6 -- Testcase --
  7 {%
  8         'use strict';
  9 
 10         try { undeclared_a = 1; } catch (e) { print(e.type, ": ", e.message, "\n"); }
 11         try { print(undeclared_a, "\n"); } catch (e) { print(e.type, ": ", e.message, "\n"); }
 12         try { undeclared_b += 2; } catch (e) { print(e.type, ": ", e.message, "\n"); }
 13         try { print(undeclared_b, "\n"); } catch (e) { print(e.type, ": ", e.message, "\n"); }
 14 %}
 15 -- End --
 16 
 17 -- Expect stdout --
 18 Reference error: access to undeclared variable undeclared_a
 19 Reference error: access to undeclared variable undeclared_a
 20 Reference error: access to undeclared variable undeclared_b
 21 Reference error: access to undeclared variable undeclared_b
 22 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt