#Print incompatible with Statement

1 messages · Page 1 of 1 (latest)

ruby tinsel
#
public sealed interface Statement permits Print
{
    void run();
}

public record Print(Expression expression) implements Statement
{
    public void run()
    {
        System.out.print(ExpressionEval.evaluate(expression));
    }
}

    private Statement parsePrint()
    {
        if (Objects.requireNonNull(peek()).type() == TokenType.NUMBER)
            return new Print(giveExpression()); // error
    }
    Expression giveExpression()
    {
        return parseExpression();
    }
astral cipherBOT
#

<@&987246399047479336> please have a look, thanks.

left cloak
#

hm?

#

are you sure its not just because you dont return always

ruby tinsel
#

no

#

it says Incompatible types. Found: 'geletin.jelly.statements.Print', required: 'geletin.jelly.Statement'

left cloak
#
    private Statement parsePrint()
    {
        if (Objects.requireNonNull(peek()).type() == TokenType.NUMBER) {
            return new Print(giveExpression()); // error
        }
        else {
            throw new RuntimeException();
        }
    }
ruby tinsel
#

Statement only lives in statements package

left cloak
#

do you have two Statement classes in your project?

ruby tinsel
#

hold up

#

let me check

left cloak
#

geletin.jelly.Statement because clearly the compiler thinks there is one here

ruby tinsel
#

. . sry to waste your time

#

tho i never remembered making it one

#

only in statement package