Skip to content

.AND. / .OR. / .NOT. written without spaces are parsed as member access – compiles silently and fails at run time #28

Open

Description

@ilpconsulting

Visual FoxPro accepts the logical operators written directly against their operands, with no spaces. Code written in the FoxPro 2.x era uses this style everywhere. FoxDev parses name.AND.name as a chain of member accesses. Depending on what follows the operator, the result is either a syntax error or, worse, code that compiles cleanly and then fails at run time.

Repro A – compiles, fails at run time

LOCAL x, y
x = .T.
y = .F.
? x.AND.y
? x .AND. y
  • foxvm check → ok (0 warning(s))
  • foxvm disasm → line 4 is compiled as LoadLocal(0) GetMember("AND") GetMember("y")
  • foxvm run → Error 1924 in 01B_SILENT line 4: AND is not an object.

Repro B – syntax errors

LOCAL x, y
x = 1
y = 2
IF x=1.AND.y=2                        && OK (a numeric literal precedes the operator)
ENDIF
IF EMPTY(x).OR.!EMPTY(y)              && error: expected member name, found '!'
ENDIF
IF .NOT.EMPTY(x).AND..NOT.EMPTY(y)    && error: expected member name, found '.NOT.'
ENDIF

Expected

Same as VFP 9: .AND., .OR. and .NOT. are operator tokens wherever they appear, including straight after an identifier, ) or ]. VFP never reads x.AND.y as member access, so the input is not ambiguous.

Impact

In a sample of ~25k lines of a real application we found 119 occurrences of the silent name.AND.name / name.OR.name form alone, plus over 100 that produce a syntax error. Today code like this can't be checked statically: a clean foxvm check does not mean the program runs.

Environment: foxvm 0.1.0-nightly.20261007.f38230f, win-x64.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions