mirror of https://github.com/tbklang/tlang.git
VariableExpression in function referring to global not found #54
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 4 hours 53 minutes
Due Date
deavmi
4 hours 53 minutes
No due date set.
Depends on
#58 Switch to `generateBest()`
tlang/tlang
Reference: tlang/tlang#54
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Given the following T program:
Lookups are working for assignment but not the variable expression itself of
k
(right at the end).Technically realted to the same code handling issue #10
Solution 1
I think I see why this is returning
null
is become we use:Which uses
resolveWithin
however, we want resolve best in such a case as it looks up and outside of the function container and can then reach the global variable,k
.Secondly, this is fine for local lookups WITHIN the function container as resolveBest does a within check and if not found then looks up.
Results
Looks like it works (now stops later in emit) but we are reaching the variable it seems:
Resolution 126 assertion error
I believe this happens when entity has no parent.
Function is not paranted?
Is function not parented?
So
parseFuntion()
is called byparseTypedDeclaration()
which is called byparseName()
. Now this seems like an old parser bug or lack thereof. It seems that we never set the parenting here (this is tagentially related to our use of Context actually and issue #53, so this makes sense why we would only see it now).We are looking at the call of
parseName()
inparseBody()
. An easy fix is inparseFuncDef()
.What we need
resolveBest()
and notresolveWithin()
independency/core.d
In
parseBody()
we will callparseName()
which will have our function definition. So we can traverse downwards, however we haven't loop throughstatements ~= parseName()
(thestatements
) array) and PARENTED them to what ever calledparseBody()
.parseFUncDef
has:And returns these statements as:
Now, inside
parseTypedDeclaration()
, we callparseFuncDef()
, which then we pass said statements intonew Function()
call. However, what calls this, is several mutaully recursive calls.So I think we should check (and add
parentTo
calls):parseName()
inpublic Module parse()
Wait.... it looks like we do do this?!?!?!:
It's
generateName()
We need a
generateNameWithin()
andgenerateNameBest()
which can climb for us out of the given container - this is the problem.Slightly tangential
The crashing
isDescdant
is correct. Technically we should prpobabnly remove the assert inisDescendantr()
and place it in this (which is where it fails descedancy):This actually is better than that ack we did for:
I really don't like this hack and I think it is wrong, the
Context
should actually be set as the Context coming intogeneralPass()
(as it was before). We should revert to that ASAP and then implement the generate name methods above (see issue #56)We can fix this when we have
generateNameBest()
, blocked by #58 and #56Easy,
resolveBest()
inVariableExpression
handling independency/core.d
Fixed with commit
ddea68a73db645d85c5ddb7a46001426a4dc8c70
onvarass_vardec_dependency
branch