Skip to content

give statement with arbitrary expression produces invalid story file #171

@Natrium729

Description

@Natrium729

The compiler accepts arbitrary expressions for attributes in the give statement. However, it sometimes produces an invalid story file in that case, without emitting an error or a warning.

For example, the following works, giving the attribute with ID 2 to the room:

Attribute locked;

Object obj;

[ Main;
	print "Give bug^";
	give obj 1 + 1;
];

(Compiled with inform6 -~S~D -c test.inf)

However, if we replace 1 + 1 with a parenthesised expression such as (1 + 1) or even (locked), Quixe will show this error message when running the story : "Error: Unknown opcode #0 at pc=201". Gargoyle (git) also complains with a different error message: "Fatal error: too many (48) locals at 0x14 (pc = 0x512)".

On one hand, that situation shouldn't happen often since authors aren't likely to use expression in that place. On the other hand, the compiler should never produce an invalid file without complaining.

I'm not sure if accepting arbitrary expressions in that place is a good idea since it leads to ambiguous syntax. But I'm not really sure what should be done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions