WASHINGTON (AP) — If President Donald Trump’s hardline stance on illegal immigration leads to large-scale deportations, among those hurt could be the U.S. economy.

That’s the view of many economists, who say the United States can’t afford to suddenly lose vast numbers of the undocumented workers who pick fruit and vegetables, build houses, bus tables, staff meat-packing plants and clean hotel rooms.

Undocumented workers account for roughly 18 percent of employment in agriculture, 13 percent in construction and 10 percent at restaurants, hotels and casinos, according to a study done last year by the National Bureau of Economic Research.

“The economic shock would cause widespread ramifications,” says Ben Gitis, director of labor market policy at the American Action Forum, a conservative think tank.

Addressing Congress on Tuesday night, Trump vowed to build “a great, great wall” to bar illegal Mexican immigrants from the United States. Even as he spoke, the president said, U.S. authorities were deporting the “bad ones.”

The president’s tough talk followed remarks he had made to CBS’s “60 Minutes” after his November election: He warned that his administration might deport 2 million to 3 million undocumented immigrants.

Yet what exactly Trump wants to do about illegal immigrants remains hazy because he has said different things at different times. On Tuesday before his speech, for example, the president had signaled a potential shift in a private meeting with news anchors. He told them he was open to legislation that would give legal status to some people living in the U.S. illegally and provide a pathway to citizenship to people who were brought to the U.S. illegally as children.

But in his speech Tuesday night, the president omitted any such suggestion. He instead promised to target people living in the United States illegally who “threaten our communities” and prey on “innocent citizens.”

Economists note that immigrants, including undocumented workers, play a vital role in the U.S. economy, and not only because they fill many low-paying jobs that Americans won’t or can’t do. The United States, like Japan and Western Europe, is being hobbled economically by an aging and slower-growing workforce. Economic growth depends on a steadily growing supply of workers.

But aging baby boomers are retiring. And an unusually large proportion of prime-age men have stopped looking for work. Nearly eight years after the end of the Great Recession, the unemployment rate has fallen to 4.8 percent, near what economists consider full employment.

As older Americans retire, younger ones are increasingly choosing to enroll in college rather than start work right out of high school. A result is that it’s become harder for employers to fill the entry-level jobs that are often taken by undocumented immigrants.

Gitis reviewed the numbers and said he reached a striking conclusion: Suppose, he says, the United States were to deport or otherwise lose all its estimated 6.8 million undocumented workers. At full employment, there wouldn’t be enough Americans or legal immigrants to fill all those jobs. At least 4 million jobs would go unfilled.

Still, critics have often argued that low-wage immigrants in the United States end up depressing pay for everyone else. And economists have long wrangled over that possibility.

A paper issued last month by the National Bureau of Economic Research studied what happened in 1964 when the government cut the supply of seasonal Mexican farm workers entering the United States. By excluding the Mexicans, the move was supposed to create jobs for American farm workers and raise their wages.

But researchers Ethan Lewis of Dartmouth College and Michael Clemens and Hannah Postel of the Center for Global Development found that barring Mexican farm workers “failed to raise wages or substantially raise employment for domestic workers.” Instead of hiring Americans, farms turned to machines to pick cotton and tomatoes and to tend to sugar beets.

Economist Ryan Edwards of Mills College says U.S. employers would likely shrink their businesses — rather than search in vain for legal workers — if they lost undocumented workers to mass deportations.

The cutbacks could take a heavy economic toll. Edwards and Francesc Ortega of the City University of New York estimate that undocumented workers account for 3 percent of private gross domestic product — the broadest measure of economic output — or nearly $5 trillion over 10 years.

Mass deportations could impose other costs as well. Gitis estimates that the government would have to spend $400 billion to $600 billion to deport all undocumented workers and prevent future illegal immigration.

In a 2013 study, the Social Security Administration found that undocumented workers had paid $13 billion into Social Security in 2010 and received only $1 billion in benefits. The administration concluded that illegal immigrants’ earnings had had “a net positive effect” on Social Security finances.

So mass deportations mean “we’d not only be losing workers,” Gitis says. “We’d lose consumers, even taxpayers.”