diff --git a/src/scenic/syntax/veneer.py b/src/scenic/syntax/veneer.py index 7b03cc799..4b550fbdd 100644 --- a/src/scenic/syntax/veneer.py +++ b/src/scenic/syntax/veneer.py @@ -249,6 +249,7 @@ import sys import traceback import typing +import warnings from scenic.core.distributions import ( Distribution, @@ -1521,6 +1522,11 @@ def alwaysProvidesOrientation(region): return sample.orientation is not None or sample is nowhere except RejectionException: return False + except Exception as e: + warnings.warn( + f"While sampling internally to determine if a random region provides an orientation, the following exception was raised: {repr(e)}" + ) + return False def OffsetBy(offset): diff --git a/tests/syntax/test_specifiers.py b/tests/syntax/test_specifiers.py index fe5e677f3..274e875e1 100644 --- a/tests/syntax/test_specifiers.py +++ b/tests/syntax/test_specifiers.py @@ -1198,3 +1198,19 @@ def test_color(): ego = new Object with color (1,1,1,1,1) """ sampleEgoFrom(program) + + +# alwaysProvidesOrientation +def test_alwaysProvidesOrientation_exception(): + with pytest.warns(UserWarning): + compileScenic( + """ + from scenic.core.distributions import distributionFunction + + @distributionFunction + def foo(bar): + assert False + + new Object in foo(Range(0,1)) + """ + )