From 43cd43ef3ecfc459149512634b8b68e02539ea07 Mon Sep 17 00:00:00 2001 From: TechnikTil Date: Sun, 6 Jul 2025 22:21:04 -0600 Subject: [PATCH 1/2] add `default` to enum switches --- hscript/Interp.hx | 1 + hscript/Printer.hx | 2 ++ hscript/Tools.hx | 2 ++ 3 files changed, 5 insertions(+) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index b1b6cb3..5751514 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -542,6 +542,7 @@ class Interp { return expr(e); case ECheckType(e,_): return expr(e); + default: } return null; } diff --git a/hscript/Printer.hx b/hscript/Printer.hx index b6310a8..0e0b8d3 100644 --- a/hscript/Printer.hx +++ b/hscript/Printer.hx @@ -332,6 +332,8 @@ class Printer { add(" : "); addType(t); add(")"); + default: + add("???"); } } diff --git a/hscript/Tools.hx b/hscript/Tools.hx index 2153d3f..0ae37e5 100644 --- a/hscript/Tools.hx +++ b/hscript/Tools.hx @@ -58,6 +58,7 @@ class Tools { if( def != null ) f(def); case EMeta(name, args, e): if( args != null ) for( a in args ) f(a); f(e); case ECheckType(e,_): f(e); + default: null; } } @@ -88,6 +89,7 @@ class Tools { case ESwitch(e, cases, def): ESwitch(f(e), [for( c in cases ) { values : [for( v in c.values ) f(v)], expr : f(c.expr) } ], def == null ? null : f(def)); case EMeta(name, args, e): EMeta(name, args == null ? null : [for( a in args ) f(a)], f(e)); case ECheckType(e,t): ECheckType(f(e), t); + default: null; } return mk(edef, e); } From 1fb96d67178419c70ddeae50693e8e9bf5790630 Mon Sep 17 00:00:00 2001 From: TechnikTil Date: Mon, 7 Jul 2025 12:15:59 -0600 Subject: [PATCH 2/2] wrap everything around `hscript_extraExprs` --- hscript/Interp.hx | 3 +++ hscript/Printer.hx | 4 +++- hscript/Tools.hx | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 5751514..ffc9029 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -542,7 +542,10 @@ class Interp { return expr(e); case ECheckType(e,_): return expr(e); + #if hscript_extraExprs default: + throw '$e is unknown'; + #end } return null; } diff --git a/hscript/Printer.hx b/hscript/Printer.hx index 0e0b8d3..035fa8e 100644 --- a/hscript/Printer.hx +++ b/hscript/Printer.hx @@ -332,8 +332,10 @@ class Printer { add(" : "); addType(t); add(")"); + #if hscript_extraExprs default: - add("???"); + throw '${#if hscriptPos e.e #else e #end} is unknown'; + #end } } diff --git a/hscript/Tools.hx b/hscript/Tools.hx index 0ae37e5..cecf7db 100644 --- a/hscript/Tools.hx +++ b/hscript/Tools.hx @@ -58,7 +58,10 @@ class Tools { if( def != null ) f(def); case EMeta(name, args, e): if( args != null ) for( a in args ) f(a); f(e); case ECheckType(e,_): f(e); - default: null; + #if hscript_extraExprs + default: + throw '${expr(e)} is unknown'; + #end } }