JohnEarnest/Octo

Undefined names reported as at the end of the file instead of the line they're seen

pushfoo opened this issue · 0 comments

Undefined names are currently reported at the end of the file instead of on the line where they are seen.

I've encountered this with hundreds of lines between the original usage of a token (a misdefined constant) and the end of a file. I think beginners will find it even more confusing than I did. Addressing this will also solve some of the problems I mentioned in the comments of #128 , as the malformed constant definitions (: const CONSTANT_NAME 5) will be highlighted to the user as incorrect even though we are not explicitly creating a fix for bad constant definitions.

As an example, each of the UNDEFINED_X tokens and NOOP below will be reported in a single error attributed to the last line of the file:

# legal definition
:const FIVE 5

: data_label # bad data label
 FIVE UNDEFINED_1

# bad constant definition. It would be a legal data label definition if UNDEFINED_2 was defined, but it isn't.
: const UNDEFINED_2 5


: filler_label # doesn't do anything, but the NOOP macro is omitted here
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
	NOOP
return

: another_label # more undefined values
	UNDEFINED_3 UNDEFINED_4

: main
	 filler_label
	 v1 := 2