We all know someone like this: a friend who over and over again falls for the wrong man, or a talented colleague who bounces from job to job because he seemingly cannot tolerate any kind of authority. Sigmund Freud called this the “repetition compulsion”—a psychological pattern where people repeat the same bad behaviors despite being aware of their negative outcomes.

But this phenomenon doesn’t only afflict individuals. It also affects political groups and even entire nations that get enthralled by leaders whose ideas have already been tried and exposed as failures. These bad ideas, which should be dead and buried, have a way of periodically reappearing and gaining popularity.

Several years ago, I called this condition “ideological necrophilia”: “Necrophilia is a sexual attraction to cadavers. Ideological necrophilia is the blind fixation with dead ideas. It turns out this pathology is more common in its political rather than sexual form. Turn on your TV tonight and I bet you will see some politician passionately in love with an idea that has already been tried and failed, or defending beliefs that have been proven false by incontrovertible evidence.”

Maoism is a good example. The doctrine stressed the need for “permanent revolution,” insisted that peasants should be the central protagonists of political and economic life, made agricultural collectivization the norm, and privileged small industries over large-scale economic units. Mao Zedong’s Cultural Revolution, Great Leap Forward, and other policies wrought havoc on the nation, producing a massive famine and eventually leaving more than 40 million Chinese dead. In the 1980s, an assessment of Mao’s legacy by an official Chinese newspaper concluded: “In his later years he made big mistakes over a long period, and the result was great disaster for the people and his country. He created a historical tragedy.” Such stark conclusions should have bankrupted Mao’s ideas, yet self-proclaimed Maoist rebels and political parties remain in a surprising number of countries.

Peronism is another example. Argentina has the dubious distinction of being the only country that managed to “un-develop” itself after reaching standards of living equivalent to those in developed countries. Prolonged national enthusiasm for Peronism in its many forms is largely to blame for this devolution. President Juan Domingo Perón, who led the country in the 1940s and 50s, and then again in the 70s, was a prodigy of the populism that has become so prominent in Latin America and beyond. He and his imitators stoked nationalism, made promises that were impossible to keep, exploited wedge issues along racial, ethnic, or religious lines, and distributed resources in the name of the poor in ways that in the long run made everyone poorer.

Of course, politicians everywhere say what people want to hear. But populists take this much further. Consider, for example, Venezuela’s Hugo Chávez, a great 21st-century exponent of extreme populism. Before his death in 2013, he doggedly pursued policies known to have failed in Venezuela and elsewhere: fixing prices of goods and services at levels below their costs of production; wresting private companies from their owners and giving them to politically appointed operatives; allowing government spending and indebtedness to skyrocket; promoting consumer spending through unsustainable handouts, subsidies, and credits; discouraging investment; stimulating imports rather than exports; and imposing strict foreign-exchange controls.

The result: The country with the largest oil reserves on the planet is now importing gasoline. It suffers from the world’s highest inflation rate and critical shortages of food, medicine, spare parts, and much else. A nation that used to have the highest income per capita in Latin America is now in the midst of a humanitarian crisis. What used to be one of the longest-running democracies in the region is now a failed state run by a government that relies on the military to indulge in all kinds of authoritarian abuses. And yet, Chávez’s ideas and policies continue to attract admirers in Venezuela and abroad.

Ideological necrophilia can be found in all schools of thought: on the right and the left, among environmentalists, secessionists, and nationalists, faith-based politicians and atheists, defenders of the free market, champions of big government, or supporters of economic austerity.

In the United States, Donald Trump has proposed deporting 11 million undocumented immigrants en masse, building a wall along the Mexican-American border, and enacting a moratorium on all Muslims wishing to visit or immigrate to the U.S. His plans echo Europe’s tragic history of singling out “dangerous” social groups for discrimination and expulsion from their homes. For years, the United States has constructed walls and fences to keep immigrants from crossing the border, without solving the problem of illegal immigration. The assumption that, in the age of globalization, a larger, longer, higher wall will deter migrants is deeply flawed as well. Not only would these ideas fail to deliver their promised results, but they are also close to impossible to implement. Yet it is now obvious that this is irrelevant. In fact, these bad ideas are precisely the reason Trump’s followers are drawn to him.

Ted Cruz, Trump’s fellow Republican presidential candidate, has argued that “carpet–bombing” ISIS territory in Syria and Iraq is the best way to combat the group. He conveniently disregards the fact that the Islamic State’s doctrine is gaining adherents in Europe, the United States, and Asia, and that ISIS today is more an amorphous source of inspiration than an organization with a permanent address. And it’s not as if the United States doesn’t have experience with massive bombing campaigns in faraway countries that achieved exactly the opposite of what their Washington planners intended. Writing in The Atlantic several years ago, Henry Grabar vividly described how the U.S. in the 1960s and 70s dropped more explosives on Cambodia than the Allies had unleashed in all of World War II, killing an untold number of people. Hundreds of thousands of villagers were forced to flee to the capital, leading to overcrowding and food scarcity; rural Cambodians who had previously been politically neutral were radicalized. These conditions may have contributed to the rise of the genocidal Khmer Rouge in the country.

The Republican candidates hardly have a lock on ideological necrophilia. Bernie Sanders’s attraction to massive, government-centered programs places him squarely among populists who dismiss the need to maintain fiscal balances and end up with unsustainable government budget deficits. The plans on his campaign website would amount to an estimated $18 trillion to $30 trillion in new spending over the next 10 years. In pledging a form of European-like socialism to throngs of adoring young people, he doesn’t mention that if they were European, many of them would be unemployed and without prospects of finding a well-paying job. The bottom line: Many of his policies have already been tested, and many don’t work all that well.

In a world in which a few keystrokes on a computer can lead to a wealth of information about the track record of a particular economic or political proposal, it’s surprising that ideological necrophilia is still so common. There are many reasons why bad ideas endure, but perhaps the most important is people’s need to believe in a leader when faced with the grave anxieties and uncertainties associated with rapid change—and the demagogue’s inclination in these fragile moments to promise anything, even the discarded notions of demagogues past, in order to obtain and retain power.