FluxSharp Compiler - Error Messages Guide
Quick Reference
When you compile FluxSharp code with
fluxc
, the compiler will show you clear error messages if something is wrong.
Common Errors and How to Fix Them
โ Missing Semicolon
What you write:
int x = 10
Error message:
โ POSSIBLE SYNTAX ERROR at line 3:
int x = 10
Hint: Statement appears to be missing a semicolon (;) at the end
Expected format: int x = 10;
How to fix it: Add a semicolon at the end of the line:
int x = 10;
โ ๏ธ Float Literal Format
What you write:
float f = 3.14;
Error message:
โ ๏ธ FLOAT LITERAL ERROR at line 3:
float f = 3.14;
Hint: Float literals must end with 'f' or 'F'
Correct format: 3.14f or 3.14F
How to fix it: Add 'f' or 'F' after the decimal number:
float f = 3.14f; // or 3.14F
Note: Double literals can use scientific notation without 'f':
double d = 3.14; // OK
double d = 3.14e-2; // OK
โ Unmatched Parenthesis
What you write:
int x = max(10, 20;
Error message:
โ UNMATCHED PARENTHESIS at line 3:
int x = max(10, 20;
Hint: Found 1 opening '(' but only 0 closing ')'
How to fix it: Add the missing closing parenthesis:
int x = max(10, 20);
โ Unmatched Bracket
What you write:
int arr[10;
Error message:
โ UNMATCHED BRACKET at line 3:
int arr[10;
Hint: Found 1 opening '[' but only 0 closing ']'
How to fix it: Add the missing closing bracket:
int arr[10];
โ Undefined Variable
What you write:
print(y); // y was never declared
Error message:
โ Undefined variable: 'y'
Make sure this variable is declared before use with: type y = value;
How to fix it: Declare the variable before using it:
int y = 10;
print(y);
โ Undefined Function
What you write:
int result = myfunction(10);
Error message:
โ Undefined function: 'myfunction'
Available math functions: abs, max, min, pow, floor, ceil, round, sqrt
How to fix it: Use only available functions or check the spelling:
int result = abs(-10); // Use a valid function
โ Function Argument Count
What you write:
int x = max(10); // max() needs 2 arguments
Error message:
โ Function Error: max() requires exactly 2 arguments, but got 1
Usage: max(value1, value2)
How to fix it: Provide the correct number of arguments:
int x = max(10, 20);
โ ๏ธ Type Mismatch in Function
What you write:
int x = max(10, 3.14f); // Can't mix int and float
Error message:
โ ๏ธ Type Error: max() requires both arguments to be the same numeric type
Use: max(intA, intB), max(floatA, floatB), or max(doubleA, doubleB)
How to fix it: Use the same type for both arguments:
int x = max(10, 20); // Both int
// OR
float x = max(3.14f, 2.71f); // Both float
Available Math Functions
All these functions are available in FluxSharp:
Function | Purpose | Example |
|---|---|---|
| Absolute value | returns |
| Maximum of two values | returns |
| Minimum of two values | returns |
| Power function | returns |
| Square root | returns |
| Round down | returns |
| Round up | returns |
| Round to nearest | returns |
Type System
FluxSharp supports these primitive types:
Type | Description | Example |
|---|---|---|
| Integer (32-bit) | |
| Long integer (64-bit) | |
| Floating-point (32-bit) | |
| Double precision (64-bit) | |
| Text | |
| Boolean | |
| Single byte | |
| No value (functions only) | |
Writing Valid FluxSharp Code
Rule 1: Always end statements with semicolons
int x = 10; // โ Correct
print(x); // โ Correct
int y = 20 // โ Wrong - missing semicolon
Rule 2: Match all parentheses and brackets
int x = (10 + 20); // โ Correct
int arr[10]; // โ Correct
int y = (10 + 20; // โ Wrong - missing )
Rule 3: Declare variables before using them
int x = 10; // โ Correct
print(x); // โ Now x is defined
print(y); // โ Wrong - y doesn't exist
Rule 4: Use correct type suffixes for floats
float f = 3.14f; // โ Correct
float g = 2.71f; // โ Correct
float h = 1.41; // โ Wrong - missing 'f'
Rule 5: Match function argument types
int x = max(10, 20); // โ Correct - both int
float y = max(3.14f, 2.71f); // โ Correct - both float
int z = max(10, 3.14f); // โ Wrong - mixed types
Tips for Error-Free Code
Use an editor with syntax highlighting - It helps you spot errors visually
Check semicolons first - Most errors are missing semicolons
Pay attention to float literals - Don't forget the 'f' suffix
Count parentheses and brackets - Every ( needs a ), every [ needs a ]
Declare before using - Always declare variables before you use them
Check function names - Use only the available built-in functions
Match argument types - Functions require specific types
Testing Your Code
The compiler provides a test script to verify all error detection:
bash testcompilererrors.sh
This runs 5 tests demonstrating:
Missing semicolon detection
Float literal format detection
Unmatched parenthesis detection
Valid compilation (no errors)
Unmatched bracket detection
Getting Help
If you see an error message:
Read the line number - Find the exact line with the problem
Read the hint - The hint explains what went wrong
Check the example - The message shows the correct format
Refer to this guide - Look up the error type above
Remember: Error messages are your friends! They tell you exactly what's wrong so you can fix it quickly.