oden/fine/tests/expression/conditional.fine

79 lines
1.8 KiB
Text

fun test() -> f64 {
if true { "discarded"; 23 } else { 45 }
}
// @no-errors
// Here come some type probes!
// (type of the condition)
// @type: 27 bool
//
// (the discarded expression)
// @type: 34 string
//
// (the "then" clause)
// @type: 47 f64
// @type: 50 f64
//
// (the "else" clause)
// @type: 59 f64
// @type: 62 f64
//
// @concrete:
// | File
// | FunctionDecl
// | Fun:'"fun"'
// | Identifier:'"test"'
// | ParamList
// | LeftParen:'"("'
// | RightParen:'")"'
// | ReturnType
// | Arrow:'"->"'
// | TypeExpression
// | TypeIdentifier
// | Identifier:'"f64"'
// | Block
// | LeftBrace:'"{"'
// | IfStatement
// | ConditionalExpression
// | If:'"if"'
// | LiteralExpression
// | True:'"true"'
// | Block
// | LeftBrace:'"{"'
// | ExpressionStatement
// | LiteralExpression
// | String:'"\"discarded\""'
// | Semicolon:'";"'
// | ExpressionStatement
// | LiteralExpression
// | Number:'"23"'
// | RightBrace:'"}"'
// | Else:'"else"'
// | Block
// | LeftBrace:'"{"'
// | ExpressionStatement
// | LiteralExpression
// | Number:'"45"'
// | RightBrace:'"}"'
// | RightBrace:'"}"'
//
// @compiles-to:
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (2):
// | 0: PushNothing
// | 1: Return
// | function test (0 args, 0 locals):
// | strings (1):
// | 0: "discarded"
// | code (8):
// | 0: PushTrue
// | 1: JumpFalse(6)
// | 2: PushString(0)
// | 3: Discard
// | 4: PushFloat(23.0)
// | 5: Jump(7)
// | 6: PushFloat(45.0)
// | 7: Return
// |
// @eval: Float(23.0)