Skip to content

Commit 54bf364

Browse files
authored
Slightly tweak how functions are suggested in not found error messages (#1243)
1 parent 2807103 commit 54bf364

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

compiler/typecheck/step3_function_and_method_bodies.jou

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,9 @@ def typecheck_call(state: State*, call: AstCall*, location: Location) -> Type*:
770770
snprintf(msg, sizeof(msg), "function '%s' not found", call.function.varname)
771771
match call.function.varname with strcmp:
772772
case "print":
773-
strcat(msg, ", try 'printf' from \"stdlib/io.jou\"")
773+
strcat(msg, ", try printf() from \"stdlib/io.jou\"")
774774
case "input":
775-
strcat(msg, ", try 'fgets' from \"stdlib/io.jou\"")
775+
strcat(msg, ", try fgets() from \"stdlib/io.jou\"")
776776
fail(call.function.location, msg)
777777

778778
funcptr_type = typecheck_expression_not_void(state, call.function, NULL)
@@ -1242,11 +1242,11 @@ def typecheck_expression(state: State*, expr: AstExpression*, type_hint: Type*)
12421242
snprintf(msg, sizeof(msg), "no variable named '%s'", expr.varname)
12431243
match expr.varname with strcmp:
12441244
case "stdin":
1245-
strcat(msg, ", try 'get_stdin()' from \"stdlib/io.jou\"")
1245+
strcat(msg, ", try get_stdin() from \"stdlib/io.jou\"")
12461246
case "stdout":
1247-
strcat(msg, ", try 'get_stdout()' from \"stdlib/io.jou\"")
1247+
strcat(msg, ", try get_stdout() from \"stdlib/io.jou\"")
12481248
case "stderr":
1249-
strcat(msg, ", try 'get_stderr()' from \"stdlib/io.jou\"")
1249+
strcat(msg, ", try get_stderr() from \"stdlib/io.jou\"")
12501250
case "Null" | "null":
12511251
strcat(msg, ", try NULL")
12521252
case "TRUE" | "true":
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def main() -> int:
2-
name = input("What's your name? ") # Error: function 'input' not found, try 'fgets' from "stdlib/io.jou"
1+
def blah() -> None:
2+
name = input("What's your name? ") # Error: function 'input' not found, try fgets() from "stdlib/io.jou"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def main() -> int:
2-
print("Hello") # Error: function 'print' not found, try 'printf' from "stdlib/io.jou"
1+
def blah() -> None:
2+
print("Hello") # Error: function 'print' not found, try printf() from "stdlib/io.jou"

tests/404/stderr.jou

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import "stdlib/io.jou"
22

3-
def main() -> int:
4-
fprintf(stderr, "hi\n") # Error: no variable named 'stderr', try 'get_stderr()' from "stdlib/io.jou"
3+
def blah() -> None:
4+
fprintf(stderr, "hi\n") # Error: no variable named 'stderr', try get_stderr() from "stdlib/io.jou"

tests/404/stdin.jou

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "stdlib/io.jou"
22

3-
def main() -> int:
3+
def blah() -> None:
44
line: byte[100]
5-
fgets(line, sizeof(line), stdin) # Error: no variable named 'stdin', try 'get_stdin()' from "stdlib/io.jou"
5+
fgets(line, sizeof(line), stdin) # Error: no variable named 'stdin', try get_stdin() from "stdlib/io.jou"

tests/404/stdout.jou

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import "stdlib/io.jou"
22

3-
def main() -> int:
4-
fprintf(stdout, "hi\n") # Error: no variable named 'stdout', try 'get_stdout()' from "stdlib/io.jou"
3+
def blah() -> None:
4+
fprintf(stdout, "hi\n") # Error: no variable named 'stdout', try get_stdout() from "stdlib/io.jou"

0 commit comments

Comments
 (0)