b32 no_stale_code : 1;
b32 show_all_errors : 1;
+ b32 enable_optional_semicolons : 1;
+
b32 generate_tag_file : 1;
b32 generate_symbol_info_file : 1;
b32 generate_lsp_info_file : 1;
switch (*tokenizer->curr) {
case '\n':
- if (tokenizer->insert_semicolon) {
+ if (tokenizer->insert_semicolon && context.options->enable_optional_semicolons) {
OnyxToken semicolon_token;
semicolon_token.type = Token_Type_Inserted_Semicolon;
semicolon_token.text = "; ";
"\t Can drastically increase binary size.\n"
"\t--generate-foreign-info Generate information for foreign blocks. Rarely needed, so disabled by default.\n"
"\t--wasm-mvp Use only WebAssembly MVP features.\n"
+ "\t--feature <feature> Enable an experimental language feature.\n"
"\n"
"Developer options:\n"
"\t--no-colors Disables colors in the error message.\n"
.no_stale_code = 0,
.show_all_errors = 0,
+ .enable_optional_semicolons = 0,
+
.runtime = Runtime_Onyx,
.files = NULL,
else if (!strcmp(argv[i], "--show-all-errors")) {
options.show_all_errors = 1;
}
+ else if (!strcmp(argv[i], "--feature")) {
+ char *next_arg = argv[++i];
+ if (!strcmp(next_arg, "optional-semicolons")) {
+ options.enable_optional_semicolons = 1;
+ }
+ }
else if (!strcmp(argv[i], "-I")) {
bh_arr_push(options.included_folders, argv[++i]);
}
// :LinearTokenDependent
OnyxToken* token_after_paren = matching_paren + 1;
+
+ // Allow for:
+ // foo :: ()
+ // -> i32 {}
+ //
+ // bar :: ()
+ // { }
+ if (token_after_paren->type == Token_Type_Inserted_Semicolon)
+ token_after_paren += 1;
+
if (token_after_paren->type != Token_Type_Right_Arrow
&& token_after_paren->type != '{'
&& token_after_paren->type != Token_Type_Keyword_Do