Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CA65: References inside of a scope aren't known outside of that scope. #796

@vrubleg

Description

@vrubleg

I use ca65 quite often, and there is an inconvenience with using .PROC: some labels require to specify the root namespace explicitly, even when there is no ambiguity.

For example, this code compiles as expected:

JSR testfunc

.IFREF testfunc
testfunc:
	RTS
.ENDIF

But, this variant doesn't:

.PROC caller
	JSR testfunc
.ENDPROC

.IFREF testfunc
testfunc:
	RTS
.ENDIF

It tells Error: Symbol 'testfunc' is undefined, but when I call the testfunc as JSR ::testfunc, it works as expected.

Probably, it was designed this way. But, it is inconsistent, sometimes it is not required to specify the root namespace. For example, this code is assembled properly without explicit root namespace:

.PROC caller
	JSR testfunc
.ENDPROC

testfunc:
	RTS

Another variation of the issue. This code is assembled as expected:

DEBUGMODE = 1

.IF DEBUGMODE
	LDA #0
.ENDIF

But, this can't be assembled:

DEBUGMODE = 1

.PROC caller
	.IF DEBUGMODE
		LDA #0
	.ENDIF
.ENDPROC

It tells Error: Constant expression expected, but when I use DEBUGMODE as .IF ::DEBUGMODE, it starts to work as expected.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions