When studying a symbol expression use its address size if its smaller than that of the symbol #2729
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This works around a piece of code known to be problematic. When a symbol is defined, the assembler studies it to determine its address size. This fails if the expression contains forward references in which case "absolute" is assumed. When later studying expressions containing this symbol, the code let the address size for the symbol override that of the actual expression. So if it was later found that a symbol expression evaluated to 8 bit ("zeropage"), since now all references could be resolved, the study function let the "absolute" value from the symbol override what it found out by evaluating the expression.
I've changed the code so that the override takes place only if the symbol has a smaller address size than what was found when evaluating the symbol expression. This might happen if a symbol is declared explicitly as zero page. On the other side, values are always enlarged as needed, so if studying a symbol results in a "zeropage" address size, the assembler will extend it to "absolute" whenever necessary. Which means that this change should be unproblematic.
Fixes #2208.