diff --git a/news/astatemacro.rst b/news/astatemacro.rst
new file mode 100644
index 00000000..c614a833
--- /dev/null
+++ b/news/astatemacro.rst
@@ -0,0 +1,24 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* Resolved issues where macro functions were not able to properly
+  accept single-line statements in ``exec`` and ``single`` mode.
+
+**Security:**
+
+* <news item>
diff --git a/xonsh/built_ins.py b/xonsh/built_ins.py
index c9cdcd60..72d9076a 100644
--- a/xonsh/built_ins.py
+++ b/xonsh/built_ins.py
@@ -1074,6 +1074,8 @@ def convert_macro_arg(raw_arg, kind, glbs, locs, *, name="<arg>", macroname="<ma
         if locs is not None:
             ctx |= set(locs.keys())
         mode = mode or "eval"
+        if mode != "eval" and not raw_arg.endswith("\n"):
+            raw_arg += "\n"
         arg = execer.parse(raw_arg, ctx, mode=mode, filename=filename)
     elif kind is types.CodeType or kind is compile:  # NOQA
         mode = mode or "eval"

Can’t capture assignment statement with ast macro
Capturing an assignment statement as an ast using a macro doesn’t seem to work for me. This may be a misunderstanding of how things are supposed to work, so shout if that’s the case!

## xonfig

<details>

```
+------------------+-----------------+
| xonsh            | 0.8.3           |
| Python           | 3.6.6           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 2.0.7           |
| shell type       | prompt_toolkit2 |
| pygments         | 2.2.0           |
| on posix         | True            |
| on linux         | False           |
| on darwin        | True            |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+
```

</details>

## Expected Behavior

I have a function `check_ast` defined as follows in my `.xonshrc`:

```
def check_ast(x: ("ast", "exec")):
    print(x)
```

When I call that as a macro with an assignment, e.g. `check_ast!(x = 5)`, I expect to see output as if I had printed an AST node. By comparison, `print(ast.parse("x = 5"))` at the python repl gives: `<_ast.Module object at 0x102f1c5c0>`.

## Current Behavior

I get `SyntaxError: None: no further code` when I run `check_ast!(x = 5)`.

### Traceback (if applicable)

<details>

```
Traceback (most recent call last):
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/base_shell.py", line 360, in default
    run_compiled_code(code, self.ctx, None, "single")
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/codecache.py", line 67, in run_compiled_code
    func(code, glb, loc)
  File "<xonsh-code>", line 1, in <module>
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/built_ins.py", line 1144, in call_macro
    raw_arg, kind, glbs, locs, name=key, macroname=macroname
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/built_ins.py", line 1065, in convert_macro_arg
    arg = execer.parse(raw_arg, ctx, mode=mode, filename=filename)
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/execer.py", line 95, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/execer.py", line 231, in _parse_ctx_free
    raise original_error from None
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/execer.py", line 216, in _parse_ctx_free
    debug_level=(self.debug_level > 2),
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/parsers/base.py", line 546, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/nix/store/zak9a1w12r66j8pdfsjabzdnd3b64h6k-python3.6-ply-3.11/lib/python3.6/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/nix/store/zak9a1w12r66j8pdfsjabzdnd3b64h6k-python3.6-ply-3.11/lib/python3.6/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/nix/store/zak9a1w12r66j8pdfsjabzdnd3b64h6k-python3.6-ply-3.11/lib/python3.6/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/parsers/base.py", line 3275, in p_error
    self._parse_error("no further code", None)
  File "/nix/store/d9sdzqk041dlz2q4sm7wb2fyxplyrnh9-xonsh-0.8.3/lib/python3.6/site-packages/xonsh/parsers/base.py", line 679, in _parse_error
    raise err
  File "<string>", line None
SyntaxError: None: no further code
```

</details>
diff --git a/tests/test_builtins.py b/tests/test_builtins.py
index bac2de58..29950df6 100644
--- a/tests/test_builtins.py
+++ b/tests/test_builtins.py
@@ -5,7 +5,7 @@ import os
 import re
 import builtins
 import types
-from ast import AST
+from ast import AST, Module, Interactive, Expression
 
 import pytest
 
@@ -326,6 +326,61 @@ def test_call_macro_raw_kwargs(arg):
     assert rtn == 42
 
 
+def test_call_macro_ast_eval_expr():
+    def f(x: ("ast", "eval")):
+        return x
+
+    rtn = call_macro(f, ["x == 5"], {}, None)
+    assert isinstance(rtn, Expression)
+
+
+def test_call_macro_ast_single_expr():
+    def f(x: ("ast", "single")):
+        return x
+
+    rtn = call_macro(f, ["x == 5"], {}, None)
+    assert isinstance(rtn, Interactive)
+
+
+def test_call_macro_ast_exec_expr():
+    def f(x: ("ast", "exec")):
+        return x
+
+    rtn = call_macro(f, ["x == 5"], {}, None)
+    assert isinstance(rtn, Module)
+
+
+def test_call_macro_ast_eval_statement():
+    def f(x: ("ast", "eval")):
+        return x
+
+    try:
+        rtn = call_macro(f, ["x = 5"], {}, None)
+        assert False
+    except SyntaxError:
+        # It doesn't make sense to pass a statement to
+        # something that expects to be evaled
+        assert True
+    else:
+        assert False
+
+
+def test_call_macro_ast_single_statement():
+    def f(x: ("ast", "single")):
+        return x
+
+    rtn = call_macro(f, ["x = 5"], {}, None)
+    assert isinstance(rtn, Interactive)
+
+
+def test_call_macro_ast_exec_statement():
+    def f(x: ("ast", "exec")):
+        return x
+
+    rtn = call_macro(f, ["x = 5"], {}, None)
+    assert isinstance(rtn, Module)
+
+
 def test_enter_macro():
     obj = lambda: None
     rtn = enter_macro(obj, "wakka", True, True)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-flake8 pytest-cov
apt-get update apt-get install -y gcc
3.7
requirements-docs.txt requirements-tests.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
Babel==2.14.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
cloud-sptheme==1.10.1.post20200504175005
codecov==2.1.13
coverage==7.2.7
cryptography==44.0.2
cycler==0.11.0
doctr==1.9.0
docutils==0.19
exceptiongroup==1.2.2
flake8==3.9.2
fonttools==4.38.0
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
iniconfig==2.0.0
Jinja2==3.1.6
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.5.3
mccabe==0.6.1
numpy==1.21.6
numpydoc==1.5.0
packaging==24.0
Pillow==9.5.0
pluggy==1.2.0
prompt_toolkit==3.0.48
psutil==7.0.0
py==1.11.0
pycodestyle==2.7.0
pycparser==2.21
pyflakes==2.3.1
Pygments==2.17.2
pyparsing==3.1.4
pytest==7.4.4
pytest-cov==4.1.0
pytest-flake8==1.1.0
pytest-timeout==2.3.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
pyzmq==26.2.1
requests==2.31.0
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==2.0.1
tornado==6.2
typing_extensions==4.7.1
urllib3==2.0.7
wcwidth==0.2.13
-e git+https://github.com/xonsh/xonsh.git@eb0c3940fcab7e92024e60f2c66aba2d7d802aec#egg=xonsh
zipp==3.15.0

name: xonsh
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - babel==2.14.0
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - cloud-sptheme==1.10.1.post20200504175005
      - codecov==2.1.13
      - coverage==7.2.7
      - cryptography==44.0.2
      - cycler==0.11.0
      - doctr==1.9.0
      - docutils==0.19
      - exceptiongroup==1.2.2
      - flake8==3.9.2
      - fonttools==4.38.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - jinja2==3.1.6
      - kiwisolver==1.4.5
      - markupsafe==2.1.5
      - matplotlib==3.5.3
      - mccabe==0.6.1
      - numpy==1.21.6
      - numpydoc==1.5.0
      - packaging==24.0
      - pillow==9.5.0
      - pluggy==1.2.0
      - prompt-toolkit==3.0.48
      - psutil==7.0.0
      - py==1.11.0
      - pycodestyle==2.7.0
      - pycparser==2.21
      - pyflakes==2.3.1
      - pygments==2.17.2
      - pyparsing==3.1.4
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - pytest-flake8==1.1.0
      - pytest-timeout==2.3.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - pyzmq==26.2.1
      - requests==2.31.0
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tomli==2.0.1
      - tornado==6.2
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - wcwidth==0.2.13
      - zipp==3.15.0
prefix: /opt/conda/envs/xonsh

tests/test_builtins.py::test_call_macro_ast_exec_expr tests/test_builtins.py::test_call_macro_ast_single_statement tests/test_builtins.py::test_call_macro_ast_exec_statement
tests/test_builtins.py::test_repath_backslash
tests/test_builtins.py::test_repath_HOME_PATH_itself tests/test_builtins.py::test_repath_HOME_PATH_contents tests/test_builtins.py::test_repath_HOME_PATH_var tests/test_builtins.py::test_repath_HOME_PATH_var_brace tests/test_builtins.py::test_helper_int tests/test_builtins.py::test_helper_helper tests/test_builtins.py::test_helper_env tests/test_builtins.py::test_superhelper_int tests/test_builtins.py::test_superhelper_helper tests/test_builtins.py::test_superhelper_env tests/test_builtins.py::test_ensure_list_of_strs[exp0-yo] tests/test_builtins.py::test_ensure_list_of_strs[exp1-inp1] tests/test_builtins.py::test_ensure_list_of_strs[exp2-42] tests/test_builtins.py::test_ensure_list_of_strs[exp3-inp3] tests/test_builtins.py::test_list_of_strs_or_callables[exp0-yo] tests/test_builtins.py::test_list_of_strs_or_callables[exp1-inp1] tests/test_builtins.py::test_list_of_strs_or_callables[exp2-42] tests/test_builtins.py::test_list_of_strs_or_callables[exp3-inp3] tests/test_builtins.py::test_list_of_strs_or_callables[exp4-<lambda>] tests/test_builtins.py::test_list_of_strs_or_callables[exp5-inp5] tests/test_builtins.py::test_list_of_list_of_strs_outer_product[inp0-exp0] tests/test_builtins.py::test_list_of_list_of_strs_outer_product[inp1-exp1] tests/test_builtins.py::test_list_of_list_of_strs_outer_product[inp2-exp2] tests/test_builtins.py::test_expand_path[~] tests/test_builtins.py::test_expand_path[~/] tests/test_builtins.py::test_expand_path[x=~/place] tests/test_builtins.py::test_expand_path[x=one:~/place] tests/test_builtins.py::test_expand_path[x=one:~/place:~/yo] tests/test_builtins.py::test_expand_path[x=~/one:~/place:~/yo] tests/test_builtins.py::test_convert_macro_arg_str[str0] tests/test_builtins.py::test_convert_macro_arg_str[s] tests/test_builtins.py::test_convert_macro_arg_str[S] tests/test_builtins.py::test_convert_macro_arg_str[str1] tests/test_builtins.py::test_convert_macro_arg_str[string] tests/test_builtins.py::test_convert_macro_arg_ast[AST] tests/test_builtins.py::test_convert_macro_arg_ast[a] tests/test_builtins.py::test_convert_macro_arg_ast[Ast] tests/test_builtins.py::test_convert_macro_arg_code[code0] tests/test_builtins.py::test_convert_macro_arg_code[compile0] tests/test_builtins.py::test_convert_macro_arg_code[c] tests/test_builtins.py::test_convert_macro_arg_code[code1] tests/test_builtins.py::test_convert_macro_arg_code[compile1] tests/test_builtins.py::test_convert_macro_arg_eval[type0] tests/test_builtins.py::test_convert_macro_arg_eval[t] tests/test_builtins.py::test_convert_macro_arg_eval[type1] tests/test_builtins.py::test_convert_macro_arg_exec[exec0] tests/test_builtins.py::test_convert_macro_arg_exec[x] tests/test_builtins.py::test_convert_macro_arg_exec[exec1] tests/test_builtins.py::test_in_macro_call tests/test_builtins.py::test_call_macro_str[x] tests/test_builtins.py::test_call_macro_str[42] tests/test_builtins.py::test_call_macro_str[x tests/test_builtins.py::test_call_macro_ast[x] tests/test_builtins.py::test_call_macro_ast[42] tests/test_builtins.py::test_call_macro_ast[x tests/test_builtins.py::test_call_macro_code[x] tests/test_builtins.py::test_call_macro_code[42] tests/test_builtins.py::test_call_macro_code[x tests/test_builtins.py::test_call_macro_eval[x] tests/test_builtins.py::test_call_macro_eval[42] tests/test_builtins.py::test_call_macro_eval[x tests/test_builtins.py::test_call_macro_exec[if tests/test_builtins.py::test_call_macro_raw_arg[x] tests/test_builtins.py::test_call_macro_raw_arg[42] tests/test_builtins.py::test_call_macro_raw_arg[x tests/test_builtins.py::test_call_macro_raw_kwarg[x] tests/test_builtins.py::test_call_macro_raw_kwarg[42] tests/test_builtins.py::test_call_macro_raw_kwarg[x tests/test_builtins.py::test_call_macro_raw_kwargs[x] tests/test_builtins.py::test_call_macro_raw_kwargs[42] tests/test_builtins.py::test_call_macro_raw_kwargs[x tests/test_builtins.py::test_call_macro_ast_eval_expr tests/test_builtins.py::test_call_macro_ast_single_expr tests/test_builtins.py::test_call_macro_ast_eval_statement tests/test_builtins.py::test_enter_macro
xonsh/built_ins.py news/astatemacro.rst
xonsh/built_ins.py news/astatemacro.rst