DIRECT mode: obj.name returns the wrong value when name matches one of iEvaluate's local variables
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
Research direction
Start by reading EWC/dWC.aplf around the proxy namespace setup, then trace iEvaluate in EWC/proxySpace/iEvaluate.dyalog and check iSyntax for the same name-hiding problem. Verify reads and assignments for affected names, including child objects, and add regression coverage; the issue asks for the full demo and Multi suites to pass.
Written by the indexing model from the issue text.
Description
[!NOTE]
Discovered during eNEW implementation
Summary
In DIRECT mode, a variable or child object inside an EWC object can't be reached through the object when its name matches one of iEvaluate's ~30 local names. F.a returns the string 'a', and F.e gives VALUE ERROR. Short names like these are common in GUI code (F.b, F.n, F.l), and some of them silently return wrong values rather than failing.
This affects every object created with eWC (and with eNEW).
Reproduce
'F1' eWC 'Form'
F1.(a e n r x)←1 2 3 4 5
F1.x ⍝ 5 ✓
F1.a ⍝ 'a' ✗ should be 1
F1.n ⍝ ' n ' ✗ should be 3
F1.e ⍝ VALUE ERROR ✗ should be 2
F1.r ⍝ VALUE ERROR ✗ should be 4
The same happens with a child object: a child named e, created with 'F.G.e' eWC 'Edit', can't be reached as F.G.e (VALUE ERROR in exec[0]).
Cause
In DIRECT mode (EWC.DIRECT=1, i.e. when 700⌶ is available), ∆WC copies proxySpace (iSyntax and iEvaluate) into every object namespace and enables 2(700⌶) on it (EWC/dWC.aplf, around fullname ⎕NS proxySpace / 2(700⌶)REF). From then on, every obj.name reference or assignment is routed through obj.iEvaluate, which evaluates the expression with ⍎ inside its own frame (exec, and r←o exec a, in EWC/proxySpace/iEvaluate.dyalog).
iEvaluate lives in the object namespace and has this header:
r←{l}iEvaluate args;z;m;v;a;i;n;o;this;exec;dot;d;e;f;caller;name;p;wgid;msg;conn;t;id;⎕TRAP;set;index;indexed;data;ixexpr;sub
Because of dynamic scoping, each of these localised names (plus r, l and args) hides the object's own variable or child object of the same name while the expression is evaluated. So F1.a evaluates iEvaluate's local a, which holds the text of the name being looked up.
Affected names (case-sensitive, so properties such as Data are not affected):
a d e f i l m n o p r t v z args caller conn data dot exec id index indexed ixexpr msg name set sub this wgid
Expected
obj.name should behave as on a plain namespace or a native GUI object: any variable or child name reads and assigns normally, whatever its name.
Suggested fix
Leave only a thin wrapper inside the object, with no common names, and move the logic into #.EWC, where its locals can't hide the object's names:
_EWC_r←{_EWC_l}iEvaluate _EWC_a
⍝ calls #.EWC.evaluateProxy with ⎕THIS, which evaluates with obj⍎expr
iSyntax (a dfn) should be checked too: it evaluates ⍎⍵ for ⎕ names, and its dfn locals (c, nc, n, x) could hide object names the same way.
To check while fixing
- Whether assignment (
F1.a←99) is also affected.F1.⎕NL 2currently givesLENGTH ERRORthrough the proxy, so this couldn't be confirmed. - Every property read and write goes through
iEvaluate, so run the full demo and Multi suites. - Add a regression test that reads and assigns a variable and a child object named after each former local.
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 6
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 12
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Dyalog/ewc
-
server
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
⎕WG returns ⍬ for properties whose value is 0 (falsy check in the default WG reply)Possibly taken @sloorush claimed this 16 days ago. Openclient
Maintainers usually reply within 2 days
-
[IDEA] : How to migrate ⎕NEW?Possibly taken A pull request linked to this issue is open or already merged. Opencustomer discussion large needs reinvestigation
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 2 days
-
customer discussion large needs reinvestigation
Difficulty 5/5 Over a week Newbie friendliness 20/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
langren1353/GM_script#847 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
ImranR98/apps.obtainium.imranr.dev#2053 · 1 comment ·
Maintainers usually reply within 6 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
521xueweihan/HelloGitHub#4573 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100