Understanding WFL error messages and how to fix them.
WFL errors fall into 4 categories:
- Parse Errors - Syntax problems
- Semantic Errors - Invalid program structure
- Type Errors - Type mismatches
- Runtime Errors - Execution failures
Cause: Using reserved keyword as variable name.
Example:
store is as 10 // ERROR: 'is' is reserved
Fix:
store is_valid as 10
Quick lookup → | Complete details →
Cause: Missing end check.
Example:
check if condition:
code
// Missing end check!
Fix:
check if condition:
code
end check
Cause: Invalid syntax.
Example:
display age plus name // If name is reserved keyword
Fix: Check for reserved keywords, verify syntax.
Cause: Using variable before declaring.
Example:
display user_name // Not defined yet
Fix:
store user_name as "Alice"
display user_name
Cause: Calling undefined action.
Example:
call greet with "World" // greet not defined
Fix:
define action called greet with parameters name:
display "Hello, " with name
end action
call greet with "World"
Cause: Incompatible types in operation.
Example:
store age as 25
store name as "Alice"
display age plus name // ERROR
Fix:
display "Name: " with name with ", Age: " with age
Cause: Function expects number, got text.
Example:
store result as abs of "hello" // ERROR
Fix:
store result as abs of -5 // Numbers only
Cause: Type checker can't determine type (usually arithmetic on untyped action parameters).
Example:
define action called process with parameters x:
store result as x plus 1 // Type of x unknown
return result
end action
Fix: This is a warning, not an error — the code still runs. This applies everywhere, including files pulled in with include from (included files are never type-checked more strictly than the main program).
Note: comparison results (a is equal to b), list/object indexing (parts[0], rec["k"]), length of, and builtin call results are all inferable and do not produce this warning.
Cause: Dividing by zero.
Example:
store result as 10 divided by 0
Fix:
check if divisor is not equal to 0:
store result as 10 divided by divisor
otherwise:
display "Cannot divide by zero"
end check
Cause: Accessing list index that doesn't exist.
Example:
store items as [1, 2, 3]
store item as items[10] // Only 3 items!
Fix:
check if 10 is less than length of items:
store item as items[10]
otherwise:
display "Index too large"
end check
Cause: Popping when list has no items.
Example:
create list empty
end list
store item as pop of empty // ERROR
Fix:
check if length of list is greater than 0:
store item as pop of list
otherwise:
display "List is empty"
end check
Cause: Opening non-existent file.
Example:
open file at "missing.txt" for reading as myfile
Fix:
try:
open file at "missing.txt" for reading as myfile
// ...
catch:
display "File not found"
end try
Cause: Insufficient permissions.
Fix: Check file permissions, run with appropriate privileges.
WFL error messages include:
[ERROR_TYPE]: Description
┌─ file.wfl:line:column
│
line │ code
│ ^ Error occurred here
Components:
- Error type - Parse, semantic, type, runtime
- Description - What went wrong
- Location - Exact line and column
- Context - Code snippet showing error
- Pointer - Visual indicator
For any error:
- Read the error message - WFL provides helpful descriptions
- Check line and column - Exact location shown
- Look for typos - Common cause of errors
- Verify syntax - Use Syntax Reference
- Check examples - WFL by Example
Still stuck?
Previous: ← Built-in Functions | Next: Development →