diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin index b9189c1f1..e484a4958 100644 --- a/core/compress/zlib/zlib.odin +++ b/core/compress/zlib/zlib.odin @@ -1,4 +1,4 @@ -#+vet !using-param +#+feature using-stmt package compress_zlib /* diff --git a/core/image/netpbm/netpbm.odin b/core/image/netpbm/netpbm.odin index 25e0228b5..6a30d135a 100644 --- a/core/image/netpbm/netpbm.odin +++ b/core/image/netpbm/netpbm.odin @@ -1,4 +1,3 @@ -#+vet !using-stmt package netpbm import "core:bytes" @@ -73,8 +72,7 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context } } - // using info so we can just talk about the header - using info + header := &info.header // validation if header.format in (PBM + PGM + Formats{.Pf}) && img.channels != 1 \ @@ -664,14 +662,14 @@ autoselect_pbm_format_from_image :: proc(img: ^Image, prefer_binary := true, for ASCII :: Formats{.P1, .P2, .P3} */ - using res.header + h := &res.header - width = img.width - height = img.height - channels = img.channels - depth = img.depth - maxval = 255 if img.depth == 8 else 65535 - little_endian = true if ODIN_ENDIAN == .Little else false + h.width = img.width + h.height = img.height + h.channels = img.channels + h.depth = img.depth + h.maxval = 255 if img.depth == 8 else 65535 + h.little_endian = ODIN_ENDIAN == .Little // Assume we'll find a suitable format ok = true @@ -680,37 +678,37 @@ autoselect_pbm_format_from_image :: proc(img: ^Image, prefer_binary := true, for case 1: // Must be Portable Float Map if img.depth == 32 { - format = .Pf + h.format = .Pf return } if force_black_and_white { // Portable Bit Map - format = .P4 if prefer_binary else .P1 - maxval = 1 + h.format = .P4 if prefer_binary else .P1 + h.maxval = 1 return } else { // Portable Gray Map - format = .P5 if prefer_binary else .P2 + h.format = .P5 if prefer_binary else .P2 return } case 3: // Must be Portable Float Map if img.depth == 32 { - format = .PF + h.format = .PF return } // Portable Pixel Map - format = .P6 if prefer_binary else .P3 + h.format = .P6 if prefer_binary else .P3 return case: // Portable Arbitrary Map if img.depth == 8 || img.depth == 16 { - format = .P7 - scale = pfm_scale + h.format = .P7 + h.scale = pfm_scale return } } diff --git a/core/image/png/png.odin b/core/image/png/png.odin index 1a7240bad..0170d3168 100644 --- a/core/image/png/png.odin +++ b/core/image/png/png.odin @@ -1,4 +1,4 @@ -#+vet !using-stmt +#+feature using-stmt package png /* diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 1ea06d096..d4f0d9d4b 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -1,5 +1,6 @@ #+vet !using-stmt !using-param #+feature dynamic-literals +#+feature using-stmt package main import "core:fmt" diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 7160f3721..12631c403 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -360,6 +360,8 @@ enum OptInFeatureFlags : u64 { OptInFeatureFlag_IntegerDivisionByZero_Self = 1u<<4, OptInFeatureFlag_IntegerDivisionByZero_AllBits = 1u<<5, + OptInFeatureFlag_UsingStmt = 1u<<6, + OptInFeatureFlag_IntegerDivisionByZero_ALL = OptInFeatureFlag_IntegerDivisionByZero_Trap| OptInFeatureFlag_IntegerDivisionByZero_Zero| @@ -384,6 +386,9 @@ u64 get_feature_flag_from_name(String const &name) { if (name == "integer-division-by-zero:all-bits") { return OptInFeatureFlag_IntegerDivisionByZero_AllBits; } + if (name == "using-stmt") { + return OptInFeatureFlag_UsingStmt; + } if (name == "global-context") { diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 835f0162a..26860db4f 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -2943,10 +2943,12 @@ gb_internal void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) error(us->token, "Empty 'using' list"); return; } - if (check_vet_flags(node) & VetFlag_UsingStmt) { + + u64 feature_flags = check_feature_flags(ctx, node); + if ((feature_flags & OptInFeatureFlag_UsingStmt) == 0) { ERROR_BLOCK(); - error(node, "'using' as a statement is not allowed when '-vet' or '-vet-using' is applied"); - error_line("\t'using' is considered bad practice to use as a statement outside of immediate refactoring\n"); + error(node, "'using' has been disallowed as it is considered bad practice to use as a statement outside of immediate refactoring"); + error_line("\tIt you do require it for refactoring purposes or legacy code, it can be enabled on a per-file basis with '#+feature using-stmt'\n"); } for (Ast *expr : us->list) { diff --git a/src/check_type.cpp b/src/check_type.cpp index af07efd8f..2452cc6d0 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1830,11 +1830,14 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para Type *specialization = nullptr; bool is_using = (p->flags&FieldFlag_using) != 0; - if ((check_vet_flags(param) & VetFlag_UsingParam) && is_using) { - ERROR_BLOCK(); - error(param, "'using' on a procedure parameter is not allowed when '-vet' or '-vet-using-param' is applied"); - error_line("\t'using' is considered bad practice to use as a statement/procedure parameter outside of immediate refactoring\n"); + + u64 feature_flags = check_feature_flags(ctx, param); + + if (is_using && (feature_flags & OptInFeatureFlag_UsingStmt) == 0) { + ERROR_BLOCK(); + error(param, "'using' has been disallowed as it is considered bad practice to use as a statement/procedure parameter outside of immediate refactoring"); + error_line("\tIt you do require it for refactoring purposes or legacy code, it can be enabled on a per-file basis with '#+feature using-stmt'\n"); } if (type_expr == nullptr) { diff --git a/src/parser.cpp b/src/parser.cpp index 06703d643..e27e184d0 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6449,6 +6449,8 @@ gb_internal u64 parse_feature_tag(Token token_for_pos, String s) { syntax_error(token_for_pos, "Invalid feature flag name: %.*s", LIT(p)); error_line("\tExpected one of the following\n"); error_line("\tdynamic-literals\n"); + error_line("\tglobal-context\n"); + error_line("\tusing-stmt\n"); error_line("\tinteger-division-by-zero:trap\n"); error_line("\tinteger-division-by-zero:zero\n"); error_line("\tinteger-division-by-zero:self\n"); diff --git a/vendor/fontstash/fontstash.odin b/vendor/fontstash/fontstash.odin index 772e379f0..33e7b68de 100644 --- a/vendor/fontstash/fontstash.odin +++ b/vendor/fontstash/fontstash.odin @@ -1,5 +1,5 @@ // An Odin-native source port of [[ Fontstash ; https://github.com/memononen/fontstash ]]. -#+vet !using-param +#+feature using-stmt package fontstash import "base:runtime"