From d2b33397cc80f2fc49c486b402b3680ac632341f Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 24 Jul 2019 22:41:46 +0200 Subject: [PATCH] optionals: better errors --- compiler/parser.v | 2 +- compiler/tests/option_test.v | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/parser.v b/compiler/parser.v index 82000374d0..279ef39684 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -761,7 +761,7 @@ fn (p mut Parser) error(s string) { } // p.scanner.debug_tokens() // Print `[]int` instead of `array_int` in errors - p.scanner.error(s.replace('array_', '[]').replace('__', '.')) + p.scanner.error(s.replace('array_', '[]').replace('__', '.').replace('Option_', '?')) } fn (p &Parser) first_run() bool { diff --git a/compiler/tests/option_test.v b/compiler/tests/option_test.v index 6e90d207fc..4b619a0416 100644 --- a/compiler/tests/option_test.v +++ b/compiler/tests/option_test.v @@ -10,6 +10,7 @@ fn test_err(){ } fn err_call(ok bool) ?int { +return 'sdf' if !ok { return error('Not ok!') }